Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

I am having a struggle with satisfying both test 118 and 19. I cannot seem to figure it out.

Your code so far

distance_mi = 10
is_raining = False
has_bike = True
has_car = False
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 is_raining == True:
    print('False')
elif distance_mi > 1 and distance_mi <= 6:
    print('True')
elif has_bike == True and not is_raining == False:
    print('True')
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
    print('True')
elif distance_mi > 6 and has_car == False and has_ride_share_app == 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

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

I am testing your code with this for test 18, it prints True

you have this condition, it’s only checking the distance, not other things

test 19 has a similar problem

Still having issues with 19, cannot see how it is any different to the way i done test 18

distance_mi = 10
is_raining = False
has_bike = True
has_car = False
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 is_raining == True:
    print('False')
elif distance_mi > 1 and distance_mi <= 6 and is_raining == True and has_bike == False:
    print('False')
elif distance_mi > 1 and distance_mi <= 6 and has_bike == True and is_raining == False:
    print('True')
elif has_bike == True and not is_raining == False:
    print('True')
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
    print('True')
elif distance_mi > 6 and has_car == False and has_ride_share_app == False:
    print('False')
elif distance_mi > 1 and distance_mi <= 6 and is_raining == False and has_bike == False:
    print('False')

test with

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

and reminder that or is executed after and, that means that if you have
A and B or C, the order is (A and B) or C, check your conditions

Managed to work it out in the end. Thank you for the advice!

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