Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Not sure how to formulate an answer to #15 and also Failed:18. When the distance is between 1 mile (excluded) and 6 miles (included), and it is raining with no bike, the program should print False.
Failed:19. When the distance is between 1 mile (excluded) and 6 miles (included), it is not raining but no bike is available, the program should print False.

Not sure how to find the way to expressing this in python code..

Your code so far


distance_mi = 0
is_raining = True
has_bike = True
has_car = False
has_ride_share_app = False


if distance_mi <=1 and is_raining !=True:
    print(True)

    
elif distance_mi >=1 and distance_mi <=6 and has_bike:
    print(True)

elif distance_mi >6 and has_car or has_ride_share_app:
    print(True)    

elif distance_mi==False:
    print("False")






    
        


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

If distance_mi is 0, does it make sense to do anymore processing?

Falsy - Glossary | MDN

here, one thing you need to be aware of with or is that this is going to be read as (distance_mi >6 and has_car) or (has_ride_share_app)

1 Like

I changed that to 3, I am using 0 to see if the code can evaluate when it is False.

dhess comment was not about changing the value of the distance_mi variable, it was to point something about the order of your evaluations

1 Like

Should you be trying to evaluate if distance_mi is falsy at the end of your code or at the beginning? And, sorry, I sent you an MDN link from the JavaScript reference, but the same falsy values should apply in Python.

EDIT: Hopefully, this is a better link: Truthy vs Falsy Values in Python - GeeksforGeeks

1 Like

I want to thank you for your guidance. I completed this short project - now lets go for the next challenge!
Following your advice, reading, taking a short break and reviewing with new eyes and trying around along with rereading the instructions made all the difference.

I come to appreciate why you are careful of leaving code out. Grind, grit and faith will lead one to the answer one seeks…