Hi, I am struggling with getting 23 of the steps. I am unsure why I am not passing as it keep saying “When the distance is greater than 6 miles and no car nor a ride share app is avaliable, the program should print False”. I have no idea what i am doing wrong as I have went through my code several times. Please help and thank you.
Your code so far
distance_mi = 0
is_raining = (bool(True))
has_bike = (bool(True))
has_car = (bool(True))
has_ride_share_app = (bool(True))
if distance_mi == False :
print('False')
elif distance_mi <= 1 and is_raining == False:
print('True')
elif (distance_mi > 1 or distance_mi <= 6) and is_raining == False and has_bike == True:
print('True')
elif distance_mi > 6 and (has_car or has_ride_share_app) :
print('True')
elif distance_mi > 6 and (not(has_car or has_ride_share_app)) :
print('False')
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/149.0.0.0 Safari/537.36
Challenge Information:
Build a Travel Weather Planner - Build a Travel Weather Planner
Do we use an or operator to check for a range of numbers?
If distance_mi = 7, will your code ever reach the following condition? Try printing messages like: print("in >1 <=6") inside your conditions to check that.
I have no idea how I could check between a range of values.
Is it ?
for i in range ()
I am very confused as I have seen this on other posts and do not understand what it means. is there any chance I could get a link to maybe resources explaining this
The conditions on either side of the or operator are evaluated separately, so if distance_mi = 7, your condition distance_mi > 1 will evaluate to True and the second condition will never be evaluated.
Instead, to constrain your if statement to a range of numbers, you would need to make sure the conditions on both sides of the operator evaluate to True.
What operator would you need to use there to make that happen?