Skip to content

Commit a5bd0fd

Browse files
Added Loops
1 parent d3adfbc commit a5bd0fd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

loops.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# diving into loops
2+
3+
# for loop:
4+
5+
#In the loop below, the range of x will be from 1 to 10 . The value will start from 1 and continue 9
6+
for x in range(1,10):
7+
print(x)
8+
9+
print("\n\n")
10+
11+
# In the loop below the value will start from 1 and will continue to 10 but the after each iteration the value will be increased by 2
12+
for x in range(1,10,2):
13+
print(x)
14+
15+
print("\n\n")
16+
17+
# Traversing a list using for loop:
18+
list = [10 ,20 ,30 ,40 ,50]
19+
for i in list:
20+
print(i)
21+
22+
23+
24+
25+
# while loop:
26+
27+
i = 10
28+
29+
while (i > 0):
30+
print (i)
31+
i-=1

0 commit comments

Comments
 (0)