I dont understand simple nested loops

Joined
Aug 26, 2022
Messages
2
Reaction score
0
for num in range(10):
for i in range(num):
print (num, end=" ") #print number
# new line after each row to display pattern correctly
print("\n")

i dont understand this at all. Can someone explain this for dummies
Cheers
 
Joined
Aug 26, 2022
Messages
2
Reaction score
0
a pyramid out of numbers. Ive tried to get my head around this simple for loop logic but it takes me a long time to actually understand whats going on
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top