Python has two
primitive loop commands:
1. while loops
2. for loops
1. The while Loop
With the while loop
we can execute a set of statements as long as a condition is true.
Example
Print i as long as i is less than 6:
i = 1
while i < 6:
print(i)
i += 1
2. The for Loop
for i in range(1,6):
print(i)
No comments:
Post a Comment