Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:

My code is showing an error on the line 15. Can you help me please?

Your code so far

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

if distance_mi == False:
    print(False)
elif distance_mi <= 1 and is_raining == False:
    print(True)
else:
    print(False)


if distance_mi < 1 and distance_mi >= 6 or (has_bike == True and is_raining == False):
    print(True)
else:
    print(False)

if distance_mi >= 6 and has_bike == 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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

Hi @Kams ,

Please organize your code so your function only prints one thing.

Happy coding!


I don’t understand your answer: it should only print one answer? Because on my computer it displays three answers.

Yes. It should only print one answer: either True or False.

Tell us what’s happening:

I reviewed my code and now I’m stuck on the points : 16, 21 et 23. Can you help me? Please !!

Your code so far

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

if distance_mi == False:
    print(False)

elif distance_mi < 1 and distance_mi >= 6 or (is_raining == False and has_bike == True):
    print(True)

    if distance_mi >= 6 and has_bike == True and    (has_ride_share_app == True):
        print(True)

        if distance_mi >= 6 and has_bike == True and (has_ride_share_app == True):
            print(False)

        elif distance_mi <= 1 and is_raining == False:
                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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Travel Weather Planner - Build a Travel Weather Planner

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

I added a couple of print statements to test. Notice that your code never gets to where you think it should go:

distance_mi = 1.5
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("in else")
                print('False')
elif distance_mi > 1 and distance_mi <= 6:
        print("in here")
        if has_bike == True and is_raining == False:
                print('True')
        else:
                print('False')

Your code above still doesn’t work. Can you help me further?

It wasn’t meant to work. It was meant to guide you to see where you have an issue in your code.