Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Iteration with 2 Variables
#2
If you want to nest loops, put one inside the other, not on top of the other:

for i in range(0, 3):
    for j in range(0, 3):
        print('#{}{}'.format(i, j))
Also, check out the itertools module. It has very useful generators for things like this: product, combinations, permutations.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Iteration with 2 Variables - by punksnotdead - Apr-10-2019, 04:54 PM
RE: Iteration with 2 Variables - by ichabod801 - Apr-10-2019, 05:46 PM
RE: Iteration with 2 Variables - by punksnotdead - Apr-12-2019, 01:02 PM
RE: Iteration with 2 Variables - by ichabod801 - Apr-12-2019, 04:47 PM
RE: Iteration with 2 Variables - by punksnotdead - Apr-12-2019, 04:58 PM
RE: Iteration with 2 Variables - by Yoriz - Apr-12-2019, 05:03 PM
RE: Iteration with 2 Variables - by punksnotdead - Apr-13-2019, 08:33 AM
RE: Iteration with 2 Variables - by DeaD_EyE - Apr-14-2019, 08:48 AM
RE: Iteration with 2 Variables - by punksnotdead - Apr-14-2019, 11:01 AM

Forum Jump:

User Panel Messages

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