Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Please help me check my code, it say that:
“When the distance is between 1 mile (excluded) and 6 miles (included), and it is raining with no bike, the program should print False.”

Your code so far

distance_mi = 6
is_raining = False
has_bike = True
has_car = True
has_ride_share_app = False
distance_check = bool(distance_mi)
if distance_check == False:
    print('False')
else:   
    if distance_mi > 6 and has_ride_share_app or has_car:
        print('True')
    elif distance_mi > 1 and has_bike and not is_raining:
        print("True")
    elif distance_mi <= 1 and not is_raining:
        print('True')
    else:
        print('False')

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

Welcome to the forum @xephuongnamsg!

Here’s how you can debug your code:

distance_mi = 0.5
is_raining = True
has_bike = True
has_car = True
has_ride_share_app = False
distance_check = bool(distance_mi)

if distance_check == False:
    print("in falsy")
    print('False')
else:   
    if distance_mi > 6 and has_ride_share_app or has_car:
        print("in > 6")
        print('True')
    elif distance_mi > 1 and has_bike and not is_raining:
        print("in > 1")
        print("True")
    elif distance_mi <= 1 and not is_raining:
        print("in <= 1")
        print('True')
    else:
        print("in else")
        print('False')

What do you see in the console?

Happy coding!

1 Like

Thanks for your help!