Workshop tests are saying I’ve failed with creating conditionals to give correct boolean values, but when I change the variables to test it the answers in the terminal change correctly?
Your code so far
distance_mi = 7
int(distance_mi)
is_raining = True
has_bike = False
has_car = False
has_ride_share_app = True
if distance_mi <= 1 and is_raining == False:
print('True')
else:
print('False')
if distance_mi > 1 and distance_mi <=6:
print('True')
elif 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
Yes. In this case, the only time you should return true is when all of these conditions are met: distance must be more than 1 and less than or equal 6 and it should not be raining and you should have a bike. Does that make sense?
You’re saying the person can commute anytime the distance is more than 1 and less than or equal to 6, and if that is not true, you’re saying if you have a bike and it’s not raining, you can commute. So, what if distance is 50 miles? Would you want to bike that far?
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
I’ve updated the code to this and only two checkmarks are now not passing, and both have to do with the middle conditional (>1 and <=6). Even if I change the booleans around to the opposite of below code it’s the same result. Changing the variables still comes up with the correct boolean in the terminal though. I’m completely stumped.
if distance_mi <= 1 and is_raining == False:
print(‘True’)
elif distance_mi > 1 and distance_mi <=6 and is_raining == False and has_bike == True:
print(‘True’)
elif distance_mi > 6 and has_car == True or has_ride_share_app == True:
print(‘True’)
else:
print(‘False’)
Thank you Cleaning up the code helped a huge amount as well as realising there was one request that I missed. I did have to step away from it for a day because I completely blocked my brain after so many attempts