what is wrong with this code? it crashes and i dont know why:
#this is for like converting days to hours
Question = input('Hey you, tell me a number of days and I will convert it into hours : ')
if Question.isdigit():
# if the user inputs a 0 which is not a valid positive number it prints this "This is a zero, please enter a positive number"
if Question == 0:
print("This is a zero, please enter a positive number")
#if the user inputs a negative number it prints this: "This is a negative number please enter a positive number"
if Question < 0:
print("This is a negative number please enter a positive number")
# now this one down over here is when the user inputs a valid positive number
if Question > 0:
print(f'{Question} Days converted to hours = {Question*24}')
# this one here is if the user inputs a letter
else:
print('You have entered a letter, please enter a positive number')```
>Solution :
You are not converting your string input to an integer. You can do this using :
Question = int(input(...))
Also, to prevent conversion errors, you can double-check (if you want) that it is in fact an integer by using:
Question = input(...)
if Question.isdigit():
Question = int(Question)
# etc.
else:
print("Input was a letter, not a number")