I’m having trouble with steps 16 and up in the Build a travel weather planner it’s saying “When the distance is 1 mile or less and it is not raining, the program should print True.”
Your code so far
distance_mi = 5
is_raining = True
has_bike = False
has_car = False
has_ride_share_app = True
if not distance_mi:
print(False)
else:
if distance_mi <= 1 and not is_raining:
print(False)
else:
print(True)
if distance_mi >= 1 or distance_mi <= 6 and has_bike:
print(True)
elif has_car or has_ride_share_app:
print(True)
else:
(False)
if not distance_mi:
print(False)
else:
if distance_mi <= 1 and not is_raining:
print(False)
elif is_raining:
print(True)
elif distance_mi >= 1 or distance_mi <= 6 and has_bike:
print(True)
elif has_car or has_ride_share_app:
print(True)
else:
(False)
it now only sends one True but still nothing changes except if i put it to 0
test with distance_mi = 0.9 and is_raining = False, what does appear in the terminal? Can you show a screenshot?
also please format your code, when it is not formatted it looses indentation which is really important in Python
There are two ways you can format your code to make it easier to read and test:
After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)
Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.
To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:
Oh, it just prints false? anyways i changed it now and it says my problem is " When the distance is 1 mile or less and it is raining, the program should print False."
distance_mi = 5
is_raining = True
has_bike = False
has_car = True
has_ride_share_app = True
if not distance_mi:
print(False)
else:
if distance_mi <= 1 and not is_raining:
print(True)
elif is_raining and has_car or has_ride_share_app and distance_mi <= 6:
print(True)
elif distance_mi >= 1 or distance_mi <= 6 and has_bike:
print(True)
elif distance_mi == 1 or distance_mi <= 6 and has_car:
print(True)
elif is_raining and distance_mi >= 1:
print(False)
else:
(False)