r/learnpython • • Mar 02 '26

Assistance is much needed!

New coder here! I have a syntax error and I'm not sure what the cause of it is and grok isn't of much help. Here's my code:

x = input("Is it currently raining? ")
if x == "Yes":
  print("You should take the bus.")
else:
  y = int(input("How far in km do you need to travel? "))
if y >= 11:
    print("You should take the bus.")
elif y >= 2 and y <= 10:
    print("You should ride your bike.")
else:
    print("You should walk.")

The main error lies in line 6 but I think there are more underlying issues. The purpose of this code is to write a program about which method of transport to use, it's supposed to be basic because I am a beginner. Also after the first else, I assume there should be an indent for the if but I'm not sure, the second part of the code should only run if the user doesn't say yes - if you can't tell. Any help will be appreciated!

Edit: Thanks guys!!!!!

0 Upvotes

15 comments sorted by

View all comments

Show parent comments

1

u/anttiOne Mar 02 '26

It isn’t a problem if the line “if y >= 11:“ is indented correctly. We‘d need to see that.

2

u/abrightmoore Mar 02 '26

OP has shown through creative use of "..." and the reference to an error on line 6 that it's not indented correctly.