Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

my code from 18 - 20 when the distance is between 1 mile excluded and 6 mile included, am confuse on this part i don’t know what to do for the code to parse, please i need any one who can touch more light on it please

Your code so far

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

if not distance_mi: 
    print('False')
    
elif distance_mi <= 1 and not is_raining:
    print('True')

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

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

else:
    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

You have a colon after one of your print lines, and in one of your conditions without parentheses, and runs before or.

2 Likes

Hi @Iskenny

When the distance is between 1 mile (excluded) and 6 miles (included), and it is raining with no bike, the program should print False.

When the variables contain these values, which condition is met?

To help you debug, try adding a different number at the end of each string to see which line is printed.

Happy coding

Hi there,

This condition is being evaluated as:

(distance_mi > 6 and has_ride_share_app) or
(has_car)

So, if has_car is True, it won’t matter what distance_mi is. This condition will always evaluate to True in that case.

Happy coding!

when i try using different number is still not passing, and it was affecting the other part , please share more light on it

i tried reviewing it (distance_mi > 6 and has_ride) or has_car there is no change, please i need more pointers

i tried reviewing it making some adjustment to the value of the distance and the bool, it still not passing the code, it seems am missing the logic needed to apply for the code to pass, please help

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

if not distance_mi: 
    print('False')
    
elif distance_mi <= 1 and not is_raining:
    print('True')

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

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

Do you really want has_ride_share_app to be evaluated separately without considering the value of distance_mi?

no, i was thinking, if he has a car, and he opt for a ride_share_app, is it not the same distance he is going to cover, or how do we determine that, please enlighten me on this.

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

Use parentheses around the two things you want to be evaluated together.

For example:

if something is true and (something else is true or another thing is true)

thanks for your guidance, patience, and support , the code finally passes
thanks for your guidance and support, the code finally pass
2 Likes
thanks, i appreciate

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.