-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.py
More file actions
63 lines (39 loc) · 943 Bytes
/
loop.py
File metadata and controls
63 lines (39 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# loops in python
names=["sanu","sebi","sanoop","sebina"]
for test in names:
print(test.upper()) # for loop
correct_pin="2335"
entered_pin=""
while correct_pin != entered_pin:
entered_pin=input("enter you correct pin") # while loop
print("Access granted")
Break
boys=[1,2,3,7,9,8,6,4,0,5]
for x in boys:
if x==5:
print(" mr 5 I find you")
break
print(x)
# continue
n=(20,40,-6,-7,-70,56,89)
for i in n:
if n < 0: # remove less than 0 num and print
continue
print(i)
# pass
n=(20,40,-6,-7,-70,56,89)
for i in n:
pass # future logic for print
count=5
while count > 0:
print(f"countdown is {count}")
count-=1
print("Times up")
# infinite loop and logic inside loop
items=[]
while True:
item=input("Add the items in your cart('you finish your shopping enter done'): ")
if item.lower() == "done":
break
items.append(item)
print(items)