Python Forum
For Loops & Variables
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For Loops & Variables
#1
for i in range(3):
    for j in range(2):
        print(j)
I don't understand how the output of this is:
0
1
0
1
0
1

-why do those variables contain these integer values already?
Thats the only part i really dont get. I understand that for every loop in i, 2 loops of j play out, that why for each loop, the value generated is first 0 then 1 but where did these values come from?
Reply


Messages In This Thread
For Loops & Variables - by aditvaddi - Jun-17-2018, 11:07 PM
RE: For Loops & Variables - by Larz60+ - Jun-17-2018, 11:18 PM
RE: For Loops & Variables - by ljmetzger - Jun-17-2018, 11:55 PM
RE: For Loops & Variables - by aditvaddi - Jun-18-2018, 12:03 AM
RE: For Loops & Variables - by ichabod801 - Jun-18-2018, 12:07 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020