Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Stuck on User Story 16: When the distance is 1 mile or less and it is not raining, the program should print True.

Your code so far

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

if not distance_mi:
    print(False)

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

    if distance_mi > 1 and distance_mi <= 6:
        print(True)
    elif has_bike == True and is_raining == False:
        print(True)
    else:
        print(False)

    if distance_mi > 6:
        print(True)
    elif has_car or has_ride_share_app == True:
        print(True)
    else:
        print(False)

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36

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 @Kurodore,

Please organize your code so it print only one thing. Currently your code is printing:

True
False
True

Also, should your code will always print True if distance_mi is greater than 1, regardless of any other variable value?

Happy coding

  1. Here’s the code so that it only prints one thing:
distance_mi = 1
is_raining = True
has_bike = False
has_car = True
has_ride_share_app = False

if not distance_mi:
    print(False)

elif distance_mi <= 1:
    if is_raining == False:
        print(True)
elif distance_mi > 1 and distance_mi <= 6:
    if has_bike == True and is_raining == False:
        print(True)
elif distance_mi > 6:
    if has_car == True or  has_ride_share_app == True:
        print(True)
else:
    print(False)
  1. I don’t think so…?

Never mind, I figured it out.