Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

please i need pointers. i can’t get past here even though on the terminal i got ‘False’ but still not able to pass also i reinterpreted the question and reconstructed the code several times all did not help.

Your code so far

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 and not is_raining:
    print(True) 
    if distance_mi > 1 and has_bike:
        print(True)

    if distance_mi <= 6 and has_bike and not is_raining:
        print(True)
    elif distance_mi > 6 and has_car or has_ride_share_app:
        print(True)
    else:
        print(False)
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/154.0.0.0 Safari/537.36

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-travel-weather-planner/694acade1d4afdbce71e5840.md`Preformatted text`

the first failed test is

16. When the distance is 1 mile or less and it is not raining, the program should print True.

When I set

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

I see in the terminal

True
False

as you should print only one thing, this result is rejected

it still tell me the same thing and that line it is referring to i can’t find any bug in there because i referred from the question or can i modify it to ignore what the question asked?

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

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

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

that first line will always print then something from inside the if-elif-else chain will also always print, that makes two things printed, you need to always print only one thing

thanks for you reply but now i made changes and it seems to be always printing one thing but still can’t past, it is still telling me the same thing am even more confused now

distance_mi = 8

is_raining = False

has_bike = True

has_car = False

has_ride_share_app = False



if not distance_mi:

    print(False)

elif distance_mi <= 1 and not is_raining and distance_mi > 1 and has_bike:

    print(True)

    

    if   distance_mi <= 6 and has_bike and not is_raining:

        print(True)

    elif distance_mi > 6 and has_car or has_ride_share_app:

        print(True)

    else:

        print(False)

else:

    print(False)

I have edited your post to be readable

There are two ways you can format your code to make it easier to read and test:

  1. After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

  1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.

To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:

now you are printing one thing only, but also printing the wrong thing

like, if we set

distance_mi = 1

is_raining = False

has_bike = True

has_car = False

has_ride_share_app = False

to satisfy test 16, I see False printed, when it should be True

now i figure my problem out which was because i did not arrange it in ascending order and also that else condition in the middle was causing me a lot of harm. now i have passed. thanks!