+ 3

How do I make my codes return output when zero is inputed

https://code.sololearn.com/cXLntgz47dWo/?ref=app

13th Aug 2021, 9:28 AM
Wisdom Ademiju
2 Answers
+ 7
Wisdom Ademiju , keeping as much as possible from your code, you could do it like this : calc_formula = 24 calc_unit = "hours" def calc_ulator(num_days): if num_days != 0: return f"{num_days } days have {calc_formula * num_days } {calc_unit }" else: return f"you entered zero, theres nun like zero days fam :)" user_input = input("hey user, input number of days and i will convert to hours\n") if user_input.isdigit(): user_input_number =int(user_input) print(calc_ulator (user_input_number)) else: print ("wrong input,please input a valid number of days")
13th Aug 2021, 10:00 AM
Lothar
Lothar - avatar
+ 3
Lothar thanks😄
13th Aug 2021, 10:02 AM
Wisdom Ademiju