How to print any math calculation on python under two “for” function?










-2














I'm new on python and I couldnt understand why this code doesnt working.
In the code I'm trying to calibrate my leds, floor number + unit number should assign to number of led.



floors = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
unitperfloor = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in floors:
for j in unitperfloor:
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))


I tried to print only i, j and I see its working properly. But when I add this numberofpixel calculation, its looping just for 1 time.










share|improve this question























  • Please look at your variables. These should be lists.
    – Fourier
    Nov 12 at 11:21










  • I tried but same,i looping for 1 time
    – Alper
    Nov 12 at 11:30










  • What do you expect unitperfloor[j] to be when j becomes 10?
    – Goyo
    Nov 12 at 11:32










  • I forgot add 11 to end of the unitperfloor.
    – Alper
    Nov 12 at 11:35















-2














I'm new on python and I couldnt understand why this code doesnt working.
In the code I'm trying to calibrate my leds, floor number + unit number should assign to number of led.



floors = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
unitperfloor = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in floors:
for j in unitperfloor:
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))


I tried to print only i, j and I see its working properly. But when I add this numberofpixel calculation, its looping just for 1 time.










share|improve this question























  • Please look at your variables. These should be lists.
    – Fourier
    Nov 12 at 11:21










  • I tried but same,i looping for 1 time
    – Alper
    Nov 12 at 11:30










  • What do you expect unitperfloor[j] to be when j becomes 10?
    – Goyo
    Nov 12 at 11:32










  • I forgot add 11 to end of the unitperfloor.
    – Alper
    Nov 12 at 11:35













-2












-2








-2







I'm new on python and I couldnt understand why this code doesnt working.
In the code I'm trying to calibrate my leds, floor number + unit number should assign to number of led.



floors = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
unitperfloor = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in floors:
for j in unitperfloor:
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))


I tried to print only i, j and I see its working properly. But when I add this numberofpixel calculation, its looping just for 1 time.










share|improve this question















I'm new on python and I couldnt understand why this code doesnt working.
In the code I'm trying to calibrate my leds, floor number + unit number should assign to number of led.



floors = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
unitperfloor = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in floors:
for j in unitperfloor:
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))


I tried to print only i, j and I see its working properly. But when I add this numberofpixel calculation, its looping just for 1 time.







python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 12:53









Cheche

828218




828218










asked Nov 12 at 11:17









Alper

12




12











  • Please look at your variables. These should be lists.
    – Fourier
    Nov 12 at 11:21










  • I tried but same,i looping for 1 time
    – Alper
    Nov 12 at 11:30










  • What do you expect unitperfloor[j] to be when j becomes 10?
    – Goyo
    Nov 12 at 11:32










  • I forgot add 11 to end of the unitperfloor.
    – Alper
    Nov 12 at 11:35
















  • Please look at your variables. These should be lists.
    – Fourier
    Nov 12 at 11:21










  • I tried but same,i looping for 1 time
    – Alper
    Nov 12 at 11:30










  • What do you expect unitperfloor[j] to be when j becomes 10?
    – Goyo
    Nov 12 at 11:32










  • I forgot add 11 to end of the unitperfloor.
    – Alper
    Nov 12 at 11:35















Please look at your variables. These should be lists.
– Fourier
Nov 12 at 11:21




Please look at your variables. These should be lists.
– Fourier
Nov 12 at 11:21












I tried but same,i looping for 1 time
– Alper
Nov 12 at 11:30




I tried but same,i looping for 1 time
– Alper
Nov 12 at 11:30












What do you expect unitperfloor[j] to be when j becomes 10?
– Goyo
Nov 12 at 11:32




What do you expect unitperfloor[j] to be when j becomes 10?
– Goyo
Nov 12 at 11:32












I forgot add 11 to end of the unitperfloor.
– Alper
Nov 12 at 11:35




I forgot add 11 to end of the unitperfloor.
– Alper
Nov 12 at 11:35












1 Answer
1






active

oldest

votes


















0














floors=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
unitperfloor=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


for i in floors:
for j in unitperfloor:
numberofpixel = j + ((i- 1) * 92)
print("floor: unit: = ".format(i,j,numberofpixel))


For fetches the value of the list element, not the index of the list.



floors=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
unitperfloor=1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in range(len(floors)):
for j in range(len(unitperfloor)):
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))





share|improve this answer






















  • Thank you! Could you explain why my code didnt worked?
    – Alper
    Nov 12 at 11:33










  • Python's for statement fetches elements, like iterators, unlike other languages.
    – myhaspldeep
    Nov 12 at 11:34










  • If you want the index use for i in enumerate(floors):
    – Sharku
    Nov 12 at 11:36










  • I think I have to leave my mind from c++ while working on python :) Thank you again!
    – Alper
    Nov 12 at 11:39










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261043%2fhow-to-print-any-math-calculation-on-python-under-two-for-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














floors=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
unitperfloor=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


for i in floors:
for j in unitperfloor:
numberofpixel = j + ((i- 1) * 92)
print("floor: unit: = ".format(i,j,numberofpixel))


For fetches the value of the list element, not the index of the list.



floors=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
unitperfloor=1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in range(len(floors)):
for j in range(len(unitperfloor)):
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))





share|improve this answer






















  • Thank you! Could you explain why my code didnt worked?
    – Alper
    Nov 12 at 11:33










  • Python's for statement fetches elements, like iterators, unlike other languages.
    – myhaspldeep
    Nov 12 at 11:34










  • If you want the index use for i in enumerate(floors):
    – Sharku
    Nov 12 at 11:36










  • I think I have to leave my mind from c++ while working on python :) Thank you again!
    – Alper
    Nov 12 at 11:39















0














floors=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
unitperfloor=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


for i in floors:
for j in unitperfloor:
numberofpixel = j + ((i- 1) * 92)
print("floor: unit: = ".format(i,j,numberofpixel))


For fetches the value of the list element, not the index of the list.



floors=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
unitperfloor=1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in range(len(floors)):
for j in range(len(unitperfloor)):
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))





share|improve this answer






















  • Thank you! Could you explain why my code didnt worked?
    – Alper
    Nov 12 at 11:33










  • Python's for statement fetches elements, like iterators, unlike other languages.
    – myhaspldeep
    Nov 12 at 11:34










  • If you want the index use for i in enumerate(floors):
    – Sharku
    Nov 12 at 11:36










  • I think I have to leave my mind from c++ while working on python :) Thank you again!
    – Alper
    Nov 12 at 11:39













0












0








0






floors=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
unitperfloor=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


for i in floors:
for j in unitperfloor:
numberofpixel = j + ((i- 1) * 92)
print("floor: unit: = ".format(i,j,numberofpixel))


For fetches the value of the list element, not the index of the list.



floors=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
unitperfloor=1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in range(len(floors)):
for j in range(len(unitperfloor)):
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))





share|improve this answer














floors=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
unitperfloor=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


for i in floors:
for j in unitperfloor:
numberofpixel = j + ((i- 1) * 92)
print("floor: unit: = ".format(i,j,numberofpixel))


For fetches the value of the list element, not the index of the list.



floors=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
unitperfloor=1, 2, 3, 4, 5, 6, 7, 8, 9, 10


for i in range(len(floors)):
for j in range(len(unitperfloor)):
numberofpixel = unitperfloor[j] + ((floors[i] - 1) * 92)
print("floor:" + str(floors[i]) + " unit: " + str(unitperfloor[j]) + " = " + str(numberofpixel))






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 11:36

























answered Nov 12 at 11:29









myhaspldeep

16017




16017











  • Thank you! Could you explain why my code didnt worked?
    – Alper
    Nov 12 at 11:33










  • Python's for statement fetches elements, like iterators, unlike other languages.
    – myhaspldeep
    Nov 12 at 11:34










  • If you want the index use for i in enumerate(floors):
    – Sharku
    Nov 12 at 11:36










  • I think I have to leave my mind from c++ while working on python :) Thank you again!
    – Alper
    Nov 12 at 11:39
















  • Thank you! Could you explain why my code didnt worked?
    – Alper
    Nov 12 at 11:33










  • Python's for statement fetches elements, like iterators, unlike other languages.
    – myhaspldeep
    Nov 12 at 11:34










  • If you want the index use for i in enumerate(floors):
    – Sharku
    Nov 12 at 11:36










  • I think I have to leave my mind from c++ while working on python :) Thank you again!
    – Alper
    Nov 12 at 11:39















Thank you! Could you explain why my code didnt worked?
– Alper
Nov 12 at 11:33




Thank you! Could you explain why my code didnt worked?
– Alper
Nov 12 at 11:33












Python's for statement fetches elements, like iterators, unlike other languages.
– myhaspldeep
Nov 12 at 11:34




Python's for statement fetches elements, like iterators, unlike other languages.
– myhaspldeep
Nov 12 at 11:34












If you want the index use for i in enumerate(floors):
– Sharku
Nov 12 at 11:36




If you want the index use for i in enumerate(floors):
– Sharku
Nov 12 at 11:36












I think I have to leave my mind from c++ while working on python :) Thank you again!
– Alper
Nov 12 at 11:39




I think I have to leave my mind from c++ while working on python :) Thank you again!
– Alper
Nov 12 at 11:39

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261043%2fhow-to-print-any-math-calculation-on-python-under-two-for-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3