Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Hello, I created this code, and it fails the tests 16, 20, 21, and 22. This is strange because I tested the code with the values the tests ask for, and the output is correct. My first try failed test 15 (one of the falsy values), so I decided to add the first if; after that, the other mentioned tests failed. I don’t know if I am doing something wrong or if this is another kind of problem, so any correction or hint is welcome..

Your code so far

distance_mi = float(7)
is_raining = False
has_bike = True
has_car = False
has_ride_share_app = False

if isinstance(distance_mi, float) == False or distance_mi == 0:
    print(False)
elif distance_mi <= 1 and is_raining == False:
    print(True)
elif 1 < distance_mi <= 6 and is_raining == False and  has_bike == True:
    print(True)
elif distance_mi > 6 and (has_car == True or           has_ride_share_app == True):
    print(True)
else:
    print(False)

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-travel-weather-planner/694acade1d4afdbce71e5840.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @Darkenis065

image

When distance_mi is 1 and it is not raining, the logic outputs False instead of True.

Happy coding

This was very helpful. The test was inputting the values directly into the variable, omitting float(). I deleted the float() and corrected the logic of the first if, and it worked. Thank you.