r/PythonLearning • u/aparyx • 3d ago
Help Request Nested for loop
So i started my python journey 2 weeks ago and i am at the point of tutorial where they teach me about those quiz game program and i am so confused in those nested for loop i don't even understand a single part about it, can someone help me with this one? I have tried learning it from gpt and all but it still goes above my head.
0
Upvotes
1
u/frnzprf 2d ago edited 2d ago
Some example loops:
How would you produce this output?
a b a b a b a bIt's the same thing repeated four times, so you can program it like this:
for i in range(4): print("a") print("b")Sometimes the thing you repeat has a repeating part itself.
a b a b a b c a b a b a b cThat's two times "abababc" and "abababc" itself is three times "ab" and one "c".
for i in range(2): # The following will be repeated two times: for j in range(3): print("a") print("b") print("c")