Hello everyone,
I am having troubles with the semantic meaning of “elif”, I don’t understand it well and I can’t pass that step, it keeps saying my code has a syntax problem in the variable “not is_rainig”, but I am not able to see it.
Thank you in advance!
Your code so far
distance_mi = 24
is_raining = True
has_bike = True
has_car = True
has_ride_share_app = True
if distance_mi <= 0:
print(False)
if distance_mi <= 1 and not is_raining:
print(True)
else:
print(False)
elif distance_mi > 1 and distance_mi <= 6 and not is_raining:
if has_bike
print(True)
elif distance_mi > 6 and has_car or has_ride_share_app:
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/17.6 Safari/605.1.15
Challenge Information:
Build a Travel Weather Planner - Build a Travel Weather Planner
Still stuck on this lab. Is the second night I spent on it and I can’t pass it.
I 'll appreciate the support!
Thanks!
Your code so far
distance_mi=3
is_raining=True
has_bike=True
has_car=True
has_ride_share_app=True
if not distance_mi:
print("False")
elif distance_mi>= 1 and not is_raining:
print("True")
else:
print("False")
if distance_mi>1 and distance_mi<=6:
print("True")
if has_bike and not is_raining:
print("True")
else:
print("False")
if distance_mi>6 and has_car or has_ride_share_app:
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/17.6 Safari/605.1.15
Challenge Information:
Build a Travel Weather Planner - Build a Travel Weather Planner
use the if..elif..else condition to get the single output which is either True or False based on your values. make sure to get one value not multiple value. Use nested if..else condition if you’re comfortable.
Finally I did a third time, but I need to find extra information for example I didn’t know it should be one only block with only one if and only one else, that the first condition "if not distance_mi: print(False) was the only if, the other conditions were “elif” and also that I was giving string values at the place of booleans attributes, it supposed to be: print(True) or print(False) instead I was incorrectly writing: print(“True”) or print(“False”). I hope this information I found will help other beginners like me, who benefits or need theory to better understand the practice. This is my code after three days of work on it and it finally passed:
removed by moderator
Thanks to everyone who gave its advice and support!
Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!
Thanks! And I am sorry, I didn’t think about that when I posted my solution it could affect others! I thought it could help! Now I know for the next time. Thanks for your guidance!