-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfor.py
More file actions
25 lines (20 loc) · 674 Bytes
/
for.py
File metadata and controls
25 lines (20 loc) · 674 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
def days_to_hours(no_of_days=1):
return f"The hours of {no_of_days} day(s) are {no_of_days*24}"
def validate_days():
try:
user_input_int = int(each)
if user_input_int > 0:
print(days_to_hours(user_input_int))
elif user_input_int == 0:
print("Zero days!")
else:
print("Negative number!")
except ValueError:
if user_input != "exit":
print("Invalid input")
user_input = ""
while user_input != "exit":
user_input = input(
"Please provide the list of days to calculate hours(type 'exit' to stop): \n")
for each in user_input.split():
validate_days()