Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

Hey I’m stuck. the only “x” I’m getting is for term no. 18.
18. When the distance is between 1 mile (excluded) and 6 miles (included), and it is raining with no bike, the program should print False. I’m suck because when I input those terms into the code, the program does print “False”. it’s the only one left but every time I change lines to mimic these terms specifically two other terms are not met.

Your code so far

distance_mi = 4
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 is_raining == False:
    print('True')
elif distance_mi <= 1 and is_raining == False and has_bike == True:
    print("True")
elif distance_mi >1 and distance_mi <=6 and is_raining == False and has_bike == True:
    print('True')
elif distance_mi >1 and distance_mi <=6 and has_bike == False and is_raining == False:
    print('False')
elif 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

Welcome to the forum @Nova_cows !

It’s best to focus on making sure you are doing what is asked in the user stories rather than relying on which tests are passing or failing.

This if statement will be evaluated as “if (distance_mi >6 and has_car == True) or (has_ride_share_app == True)”.

Does that match the related user story?

Thank you for the reply! yes its the last stipulation in the story. If the distance is greater than 6 miles:

  • You should print True if the person has a car orhas a ride-share app.

  • Otherwise, you should print False.

What happens if distance_mi is not greater than 6 but has_ride_share_app is true? The way you’ve written it, that will return true. In other words, that statement will always return true if has_ride_share_app is true.

should the part about the ride-share app be independent from the distance? or that also depend from the distance? consider how the condition is separated here, one part has the distance condition, the other doesn’t
if (distance_mi >6 and has_car == True) or (has_ride_share_app == True)

Thank you! yes this fixed the problem

Thank you! this was extremely helpful

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.