Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Workshop tests are saying I’ve failed with creating conditionals to give correct boolean values, but when I change the variables to test it the answers in the terminal change correctly?

Your code so far

distance_mi = 7
int(distance_mi)
is_raining = True
has_bike = False
has_car = False
has_ride_share_app = True

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 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

Please review the User Stories carefully. Aren’t there two more conditions to meet for this to return true?

this will print False if the distance is higher than 1 mi, but is it always false in that case?

1 Like

The two other conditions are in the elif statement right below it as I could not get it accepted anywhere else. Is this affecting it?

1 Like

I’m sorry, I’m trying to think of when it would not be false but I can’t think of anything. Could you explain further what you mean?

1 Like

for example if the distance is more than 6 miles and you have a car, that should be True, but your code make it False first

1 Like

Yes. In this case, the only time you should return true is when all of these conditions are met: distance must be more than 1 and less than or equal 6 and it should not be raining and you should have a bike. Does that make sense?

You’re saying the person can commute anytime the distance is more than 1 and less than or equal to 6, and if that is not true, you’re saying if you have a bike and it’s not raining, you can commute. So, what if distance is 50 miles? Would you want to bike that far? :slight_smile:

1 Like

remove int(distance_mi)

and start the if statement with

code removed by moderator

1 Like

hi @lpharocker1

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

got it thank you for the explaination. I will remove my post immediately

hi @ILM I posted my full working code. I cannot seem to find the delete of the post. Help me

find your posts from your profile, but your other post has already been dealt with

thank you I will be careful going forward

I’ve updated the code to this and only two checkmarks are now not passing, and both have to do with the middle conditional (>1 and <=6). Even if I change the booleans around to the opposite of below code it’s the same result. Changing the variables still comes up with the correct boolean in the terminal though. I’m completely stumped.

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

I missed the solution anyway so don’t worry :laughing:

can you please format your code so it’s readable?

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 (').

I’ve tried editing the post and it’s saying it’s too old to edit now, sorry. I’ll make sure to do it properly if I ask anything else in the future.

You don’t need to edit the original post. Just reply to a post with your updated code pasted into the reply and formatted as asked.

Just completed this, if you’re testing your code and everything does pass to the terminal correctly, try reducing the redundant coding. The multiple

else:
    print('False')

-is likely what’s driving you crazy. In other words, find a way to put these statements into one long conditional.

Thank you :slight_smile: Cleaning up the code helped a huge amount as well as realising there was one request that I missed. I did have to step away from it for a day because I completely blocked my brain after so many attempts