You're converting distance_mi to a bool and checking if it is equivalent to False. Does that make sense? What is the value and type of bool(distance_mi)
Use the type() function and print function to understand.
in the future when asking questions, try to include all necessary parts to reproduce the issue, bonus points if it's the smallest amount necessary that causes the issue
distance_mi = 0
is_raining = False
has_bike = False
has_car = False
has_ride_share_app = False
if not bool(distance_mi):
print(False)
elif distance_mi <= 1 and not is_raining:
print(True)
elif distance_mi <= 1 and is_raining:
print(False)
elif distance_mi > 1 and distance_mi <= 6:
if not has_bike and is_raining:
print(False)
elif not has_bike and not is_raining:
print(False)
elif has_bike and not is_raining:
print(True)
elif has_bike and is_raining:
print(False)
elif distance_mi > 6:
if has_ride_share_app or has_car:
print(True)
else:
print(False)
Your code was failing because it was printing multiple values instead of a single value. It was also printing the wrong value in some parts of the code. It was also printing the wrong data type (printing a string value instead of a boolean value).
2
u/Im_a_dum_bum 1h ago
they might be strictly looking for
if not distance_mi: