Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Hello
I am not able to resolve step 21 and 23. The moment I change to have a different approach, all the steps get reset even if most of the code is same.

Your code so far

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

Welcome to the forum @cfar

What happens when the is_rainingvariable is set to False?

Happy coding

hi teller thanks for the clue, but now step 23 is giving error. How can step 23 be wrong when it has no context of rain valriable?

Hi @cfar

What happens when you change is_raining to False?

Does the output change? If it changes, then the logic before the check for a ride share app is activated. In that case, the output is not dependent on the ride share app.

Happy coding

Hi @Teller

When i change to is_raining = False

Again step 21 and step 23 are not passed.

I feel that the passing is not stable earlier I was able to pass step 21 with the same set of variables and now it wont pass!

now that i am checking again the step 23 is not passed with the same set of variables

Hi @cfar

If is_raining is set to Falsethe logic below will print False to the console.

The last else if statement will not execute, therefore test 23 will fail.

Happy coding

@teller thanks so much, does that mean that i have to keep trying with combinations and permutations of the other variables too to pass the test?

also when is_raining = False

which means is_raining is not raining,

then to make is_raining as positive i need to add not

so then not is_raining means it is raining, and I update the code but then i dont pass step 20 and pass step 23 and others

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

print(‘False’)

elif 1 > distance_mi <= 6 or has_bike and is_raining:

print(‘True’)

elif distance_mi > 6 and has_ride_share_app:

print(‘True’)

You current code will fail because of the where the check for the is_raining variable is located.

Think of it as, you go to room one, nothing inside, you go to room two find a map, you go to room three step inside and fall down a hole because the room was dark. There is a torch in room four, but you’ll never get to it.

What could you do to avoid falling into a pit?

not go in the dark rooms

In your code the is_raining variable is like a pit. It takes you to the exit of the code. What can you implement in your code so you don’t exit early?

@ teller

this is were i am today, i think i am avoiding rain but not quite really…getting issue with step 20

if distance_mi == 0:

print('False') # 15

elif distance_mi <= 1 and not is_raining:

print('True') # 16

if distance_mi > 1 or distance_mi <= 6 and has_bike:

print('True') # 20

elif distance_mi > 6 and has_ride_share_app:

print('True') # 21

elif distance_mi > 6 and has_car:

print('True') # 22

else:

print('False') # 23, 17

Hi @cfar

The console shouldn’t print two results.

Happy coding

Hi @cfar

I’ve edited your post to improve the readability of the code. 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 (').

Happy coding