-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay17.py
More file actions
37 lines (29 loc) · 802 Bytes
/
Day17.py
File metadata and controls
37 lines (29 loc) · 802 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
# Loops - for and while
# While loop
# while loops executes statement while the condition is true,
# as soon as Condition value -> false interpreter come out loop
# for i in range(3):
# print(i)
# Basic while loop
print("Basic while loop example!")
i = 0
while i < 4:
print(i)
i = i + 1
print("Done with the loop")
# a little bit playing around
print("\nplaying around with while loop!")
i = int(input("\nEnter the number: "))
while i < 40:
i = int(input("Enter the number: "))
print(i)
print("Done with the loop")
# Example of else with while loop
print("Else with while loop example!")
count = 5
while count > 0:
print(count)
count = count - 1
# count = count + 1 # Will make an infinite loop due to no terminating condition
else:
print("I'm inside else")