Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

I can only get this to print false. Completely new to this and can’t see why it’s doing this. I feel like it should say print false if it’s not a number. If it is a number, check the if statement for a true result. If that fails, check the elif for a true result. if it fails again check the else statement for a true result. if that fails print false (but feel like I need a 4th statement to get it to say false at the end, hope that makes sense).

Your code so far

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

if distance_mi == 0:
    print('False')
    if distance_mi <= 1 and is_raining != 'True':
        print('True')
    elif distance_mi <= (2-6) and has_bike == 'True' and is_raining != 'True':
        print('True')
    else:
        if distance_mi > 6 and has_car == 'True' or has_ride_share_app == 'True':
            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/144.0.0.0 Safari/537.36 Edg/144.0.0.0

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

Welcome to the forum @skip

You nested the if statements, which means if the outer condition is true, then evaluate the rest of the nested code.

Also, you need to print Booleans not strings.

Happy coding

1 Like

Thank you, I didn’t realize when if statements are nested they won’t be evaluated if the outer condition was false. Will see if I can figure it out from that and correct the Booleans/strings.

1 Like

I changed the print strings so I could see which line was making the print code work but cant for the life of me figure out this won’t work any help would be greatly appreciated, also not sure how to add my new code into this chat now. Just cut and paste???

distance_mi = 1

is_raining = True

has_bike = True

has_car = True

has_ride_share_app = True

if distance_mi != 0:

if distance_mi <= 1 and is_raining != True:

    print('Tru')

elif distance_mi > 1 and distance_mi <=6 and has_bike == True and is_raining != True:

        print('Tr')

elif distance_mi > 6 and has_car == True or has_ride_share_app == True:

    print('T')

else:

    print('False')

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

There is a message in the console.

I just kept changing what was indented not understanding what it was actually doing until it passed. Where can I find info on indentations so I can try and figure out what I changed that caused it to work?

the lesson that first mentions indentation is here: https://www.freecodecamp.org/learn/python-v9/lecture-booleans-and-conditionals/how-do-conditional-statements-and-logical-operators-work

if that’s enough please let us know your questions