File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ # 2 loops
2
+
3
+ # for loop:
4
+
5
+ """
6
+ Syntax..
7
+ -> "range" : starts with 0.
8
+ -> The space after the space is called as identiation, python generally identifies the block of code with the help of indentation,
9
+ indentation is generally 4 spaces / 1 tab space..
10
+
11
+
12
+ for <variable> in range(<enter the range>):
13
+ statements you want to execute
14
+
15
+ for <varaible> in <list name>:
16
+ print(<variable>)
17
+ To print the list / or any iterator items
18
+
19
+ """
20
+
21
+ # 1. for with range...
22
+ for i in range (3 ):
23
+ print ("Hello... with range" )
24
+ # prints Hello 3 times..
25
+
26
+ # 2.for with list
27
+
28
+ l1 = [1 ,2 ,3 ,78 ,98 ,56 ,52 ]
29
+ for i in l1 :
30
+ print ("list items" ,i )
31
+ # prints list items one by one....
32
+
33
+ for i in "ABC" :
34
+ print (i )
35
+
36
+ # while loop:
37
+ i = 0
38
+ while i <= 5 :
39
+ print ("hello.. with while" )
40
+ i += 1
You can’t perform that action at this time.
0 commit comments