Tell us what’s happening:
When I change the variable qty or the bool, the output changes but all the tests fail. I am unsure of where I am going wrong on this.
Do I not have enough information in the If / elif statements to determine the correct output?
Your code so far
distance_mi = 5
is_raining = False
has_bike = True
has_car = True
has_ride_share_app = True
if not isinstance(distance_mi, int):
print("False")
elif distance_mi <=1 and is_raining == False:
print("True")
else:
print("False")
if distance_mi > 1 and distance_mi <= 6 and has_bike == True and is_raining == False:
print("True")
else:
print("False")
if distance_mi > 6 and has_car == 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/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Build a Travel Weather Planner - Build a Travel Weather Planner
ILM
February 10, 2026, 5:02pm
2
how many things is your code supposed to print? Are you sure it’s three, and not only one?
with these values
we are in this case:
specifically, we have a bike and is not raining, so it should be True
instead I see
False
True
True
I assumed with the 3 different statements it should print 3, but what I am understanding now is that I should only be getting 1 output once I run the code, correct?
If that is the case, should I bunch all of my code into a giant if / elif statement?
dhess
February 10, 2026, 5:16pm
5
What if distance is 0? That’s still an int, but is it truthy?
1 Like
I will try this and report back.
Here is what I have updated my code to. The issue that I am still running into is when I change the is_raining to true. It still outputs True.
distance_mi = .5
is_raining = False
has_bike = True
has_car = True
has_ride_share_app = True
## number 4 and 5
if distance_mi <= 0:
print("False")
elif distance_mi <=1 and is_raining == False:
print("True")
## number 6
elif distance_mi > 1 and distance_mi <= 6 and has_bike == True and is_raining == False:
print("True")
## number 7
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
print("True")
else:
print("False")
dhess
February 10, 2026, 6:34pm
8
You should use the print() function to display the result.
Please take a look at Test #14 .
I have print, but I will try to reduce the amount. Maybe it is triggering it somewhere else in the code?
dhess
February 10, 2026, 7:09pm
10
Shouldn’t your function return a result that gets printed?
ILM
February 10, 2026, 7:10pm
11
hi @dhess please take a look at the lab, there isn’t a function to create here (this is before functions are taught)
ILM
February 10, 2026, 7:11pm
12
would you mind formatting your code?
When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
dhess
February 10, 2026, 7:11pm
13
Oops! Definitely no function. Thanks for making that clear.
Revised advice: Shouldn’t your code store a result that gets printed?
EDIT: Sorry; the print statements in your code are fine; I just approached it differently when I did it. Both approaches work.
Here is what I have updated my code to. The issue that I am still running into is when I change the is_raining to true. It still outputs True.
distance_mi = .5
is_raining = False
has_bike = True
has_car = True
has_ride_share_app = True
## number 4 and 5
if distance_mi <= 0:
print("False")
elif distance_mi <=1 and is_raining == False:
print("True")
## number 6
elif distance_mi > 1 and distance_mi <= 6 and has_bike == True and is_raining == False:
print("True")
## number 7
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
print("True")
else:
print("False")
Yes, I can do that in the future, I tried to go back and edit the previous post and it would not let me due to time.
ILM
February 10, 2026, 7:14pm
15
can you double check the code you posted? nothing is indented there, it should not work
I have copied and pasted what I see, the code in the lab has indenting. I am currently only stuck on # 17 & #18
distance_mi = .5
is_raining = True
has_bike = False
has_car = True
has_ride_share_app = True
## number 4 and 5
if distance_mi <= 0:
print("False")
elif distance_mi <=1 and is_raining == False:
print("True")
## number 6
elif distance_mi > 1 and distance_mi <= 6 and has_bike == True and is_raining == False:
print("True")
## number 7
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
print("True")
else:
print("False")
ILM
February 10, 2026, 7:22pm
17
Please disregard. I have figured out the code needed to pass the lab. I won’t post it here, I just further read the questions and what was needed, added 2 more lines of code and I passed.
I’m unsure if it is the “Right way” to do it, but it worked. Thank you for the help!
ILM
February 11, 2026, 7:24am
19
as long as you figured out where the True was coming from, it’s an important thing to understand about logic operators
system
Closed
March 11, 2026, 7:25am
20
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.