-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhileloop.py
More file actions
42 lines (35 loc) · 759 Bytes
/
Copy pathwhileloop.py
File metadata and controls
42 lines (35 loc) · 759 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
#while loop
is_failed=True #boolean value
i=1 #attempt
while is_failed :
if i%2!=0: #if it is not even
i=i+1
continue #does not execute next set of code,goes back to the loop
print(f"try {i} ")
i=i+1
if i>10:
break #breaks the loop
print("better luck next time")
is_failed=True
i=1
while is_failed and i<=10: #logical in while loop
print(f"try {i} ")
i=i+1
print("better luck next time")
i=0
while i<=10:
x=0
while x<i:
print("deek",end=" ")
x+=1 #x=x+1
print("")
i+=1 #i=i+1
pin="2024"
trials=1
while trials<=3:
input_pin=input(f"trial-{trials} | pin ")
trials+=1
if input_pin==pin:
print("correct")
else:
print("incorrect")