Build a Travel Weather Planner - Build a Travel Weather Planner

Tell us what’s happening:
Describe your issue in detail here.

Please help me out
it keeps saying i need to have a distance_mi variable but it’s there

Your code so far

distance_mi = 7
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)
elif 1 < distance_mi <= 6: 
    if has_bike and not is_raining:
        print(True) 
       else:
           print(False) 
elif distance_mi > 6:
     print(has_car or has_ride_share_app)
else:
     print(False) 

Your mobile information:

itel L6002P - Android 9 - Android SDK 28

Challenge: Build a Travel Weather Planner - Build a Travel Weather Planner

Link to the challenge:

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

Hi @Busarihaleem

There is a message in the console, not sure if you can see it on mobile.

Happy coding

Yes, it shows there’s an error on line 10 and I’ve tried correcting it but still there’s no difference

here the indentation is wrong for the else, what is your updated code?

Look at these snippets and see which one should not return an error (it is only one, and try not actually running them):

if True:
    print("spam")
    else:
        print("ham")
if True:
    print("spam")
else:
    print("ham")
if True:
    print("spam")
 elif 1 + 1 == 3:
    print("ham")
else:
    print("eggs")
if True:
    print("spam")
   print("ham")
    print("eggs")

and finally (and most importantly):

if True:
    print("spam")
else:
    print("ham")
elif 1 + 1 == 3:
    print("eggs")

Afterwards, look at your code again and re-implement your if statements in the way which seems successful.
Another hint (Don’t read until you have an inkling): Indentations should always be four spaces, according to the PEP 8.
Happy coding on!

It’s now saying I need to have the distance_mi variable.

My code so far:

https://www.freecodecamp.org/learn/python-v9/lab-travel-weather-planner/build-a-travel-weather-planner

Hi @Busarihaleem

Please post your code, not a link to the challenge.

Happy coding

This is my code so far:

distance_mi = 7

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)

elif 1 < distance_mi <= 6:

if has_bike and not is_raining:

    print(True) 

   else:

     print(False) 

elif distance_mi > 6:

 print(has_car or has_ride_share_app)

else:

 print(False)

Hi @Busarihaleem

There are two ways you can format your code to make it easier to read and test:

  1. 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.)

  1. 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:

Please repost your code, make sure to follow the above instructions.

Happy coding

distance_mi = 7
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)
elif 1 < distance_mi <= 6: 
    if has_bike and not is_raining:
        print(True) 
       else:
         print(False) 
elif distance_mi > 6:
     print(has_car or has_ride_share_app)
else:
     print(False) 

Idk if it’s because you transferred your code but have multiple indentations errors after all the if/elif/else statements (I send you back to hiitmeiguess’s post).

Here, you have an else, but there is not any statement associated with it. Therefore, Python considers that your else is associated with the previous elif, which will cause an error.

The else statement is print(False).
It is the elif clause that needs to have a statement before a colon.
Happy coding

but the else still needs an elif or else before it. You need to have the else match the indentation of the elif above it, or your code will never work for an indentation error

Traceback (most recent call last):
  File "main.py", line 10
    else:
         ^
IndentationError: unindent does not match any outer indentation level

It has an elif before it which is:

elif distance_mi <= 1 and not is_raining:

no, it does not, if the indentation does not match, they are not together

It is still not passing and this is my code so far:

distance_mi = 7
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)
elif 1 < distance_mi <= 6: 
  if has_bike and not is_raining:
      print(True) 
  else:
      print(False) 
elif distance_mi > 6:
   print(has_car or has_ride_share_app)
else:
     print(False) distance_mi = 7
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)
elif 1 < distance_mi <= 6: 
    if has_bike and not is_raining:
        print(True) 
       else:
         print(False) 
elif distance_mi > 6:
     print(has_car or has_ride_share_app)
else:
     print(False)

I’ve spent weeks on this project, restarted again many times.

Hi @Busarihaleem

You posted two sets of code in your last post.

if not distance_mi:
   print(False)
elif distance_mi <= 1 and not is_raining:
        print(True) 
       else:
        print(False)
elif 1 < distance_mi <= 6: 

The else statement here is misplaced. I suggest you remove it from your code, including the print call for it.

Then take a look at the console.

Some of the elifstatements contain syntax errors.

Once you fix them, your code should pass.

Happy coding

If this is your current code now:

Then notice that you are not printing True or False here:

elif distance_mi > 6:
   print(has_car or has_ride_share_app)

the code is, because both has_car and has_ride_share_app are booleans, so has_car or has_ride_share_app is also a boolean, and print(has_car or has_ride_share_app) is printing a boolean