-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile.py
More file actions
33 lines (21 loc) · 776 Bytes
/
while.py
File metadata and controls
33 lines (21 loc) · 776 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
# while loop = execute some code WHILE some condition remains true
name = input("Enter your name: ")
while name == "":
print("You didn't enter your name")
name = input("Enter your name: ")
print(f"Hello!! {name}!!")
age = int(input("Enter your age: "))
while age < 0:
print("Your age must be positive value")
age = int(input("Enter your age: "))
print(f"Your age is {age} years old")
food = input("Enter a food you like (q to quit): ")
while not food == "q":
print(f"you like {food}")
food = input("Enter a food you like (q to quit): ")
print("Bye!!")
num = int(input("Enter a # between 1 - 10: "))
while num < 1 or num > 10:
print(f"{num} is not valid")
num = int(input("Enter a # between 1 - 10: "))
print(f"Your number is {num}")