Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

I am currently stuck on checks 15 and 16 and I believe it is because of my first if statement. I initially thought I would use the == operand to check if the distance was a falsy and input the check to 0 but that would only work with some variations of my code. Then I checked the forums and saw people use the isinstance command to check if the distance was an int and that as well only worked with certain variations of my code. So I am wondering how I could trouble shoot this issue.

Your code so far

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

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0

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

i think dude u need to remove each and every else here to complete and make sure your condition had the opposite side the keep only the last else

Welcome to the forum @antman

If distance_miis 0, then the first if statement will execute True.

When it is 0, what should output to the console?

Happy coding

The issue is likely your conditions, not the variable type. You don’t need isinstance() here—distance_mi == 0 correctly checks for zero. Go through the FCC requirements and test boundary values like 0, 1, and 6 separately. Also, simplify is_raining == False to not is_raining and has_bike == True to has_bike.

if the distance is 0 then wouldn’t it follow down to the embedded if statement, but it not in this instance, it skips to the following else statement.

also consider what happens for distance 0.5

if you have difficult following what happens in your code line by line, you can use a tool like pythontutor.com to visualize the execution

Hi @antman

Try this:

Happy coding

Hi @cartergray22,

Where in this code do you see isinstance() being used??

Happy coding

Hi @antman,

In addition to using the Python Code Visualizer that ILM suggested, you might also find this resource about falsy values helpful: Truthy vs Falsy Values in Python - GeeksforGeeks.

Happy coding

So I completed the workshop but I feel like there are some ways that I can improve it and make it more concise. Is there somewhere I can post it and discuss on ways I can improve it?

Thanks for the feedback and the support!

Hi @antman

You can share your code for feedback and discussion in I Love Programming .

Don’t forget to add a blur effect when you post your code, so it doesn’t spoil the coding experience for others.

Happy coding