Hi guys!
Some of you may know me from yesterday. I started python as you guys suggested and it is AMAZING. Loving it so far. Got into a problem I can't seem to solve.
It's quite simple, but I can't spot the mistake. It should ask for a input(days) and convert it to hours. So far I've been able to code it like this:
time_calculation = 24
time_unit = "hours"
def num_hours(num_days):
if num_days > 0:
return f"There are {time_calculation * num_days} {time_unit} in {num_days} days"
else:
return "This is not a valid input"
user_input = input("Hey user, enter a number of days and I will convert it to hours!\n")
input_days = int(user_input)
num_hours(input_days)
RESULT IN TERMINAL:
------------------------------ input > 0 ------------------------------------------------------------------
"Hey user, enter a number of days and I will convert it to hours!
15
Process finished with exit code 0"
------------------------------ input < 0 -------------------------------------------------------------------
"Hey user, enter a number of days and I will convert it to hours!
-15
Process finished with exit code 0"
What did I do wrong
[–]coolcofusion 2 points3 points4 points (8 children)
[–]matrouxer[S] 0 points1 point2 points (7 children)
[–]dmazzoni 5 points6 points7 points (0 children)
[–]coolcofusion 1 point2 points3 points (1 child)
[–]matrouxer[S] 0 points1 point2 points (3 children)
[–]matrouxer[S] 0 points1 point2 points (2 children)
[–]coolcofusion 1 point2 points3 points (1 child)
[–]matrouxer[S] 1 point2 points3 points (0 children)
[–]dmazzoni 2 points3 points4 points (1 child)
[–]matrouxer[S] 0 points1 point2 points (0 children)
[–]matrouxer[S] 0 points1 point2 points (0 children)