Kams
1
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
dhess
2
Hi @Kams ,
Please organize your code so your function only prints one thing.
Happy coding!
Kams
3
I don’t understand your answer: it should only print one answer? Because on my computer it displays three answers.
dhess
4
Yes. It should only print one answer: either True or False.
Kams
5
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
dhess
6
I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.
dhess
7
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')
Kams
8
Your code above still doesn’t work. Can you help me further?
dhess
9
It wasn’t meant to work. It was meant to guide you to see where you have an issue in your code.