It is showing syntax error

likeHangingaround = input(“Do you like hanging around?”)
if likeHangingaround ==“N”:
else(Showing syntax error):
print(“Then you’re not Spider-man!”)

likeHangingaround = input(“Do you like hanging around?”)
if likeHangingaround.lower() ==“n”:
  print(“Then you’re not Spider-man!”)

You do not need else …

Do you have any other solutions for this?

what do you mean? like

likeHangingaround = input(“Do you like hanging around?”)
if likeHangingaround.lower() ==“y”:
  pass
else:
  print(“Then you’re not Spider-man!”)

Is this what you were looking for?

likeHangingaround = input("Do you like hanging around?").lower()
if likeHangingaround =="n":
  print("Then you’re not Spider-man!")
else:
  print("Hello Spider-man!")

I included .lower() so that you do not have to worry about whether the user inputed “N” or “n”
Edit: Removed a redundant .lower(), thanks @whileTRUEpass.

1 Like

This is ok. but it is showing ==“y”:(invalid character in identifier)

can you copy the code using the preformatted text option (from the mechanical wheel options) so we have a better clue?

you can get rid of one lower :wink:

I believe this is caused by the " characters you used not being the one python expects. (You used and , and python expects ")

It could well be. In doubt use the ’

print(“Answer these questions and let’s find out.”)
print()
print(“Please use Y or N for yes and no.”)
print()

likeHangingaround = input(“Do you like hanging around?”)
if likeHangingaround ==“N”:
else:(Showing syntax error)
print(“Then you’re not Spider-man!”)

likeGravellyvoice = input(“Do you have’gravelly’ voice?”)
if likeGravellyvoice ==“N”
else:
print(“Aww, then you’re not Korg”)

likeMarvelous = input(“Do you feel Marvelous?”)
if likeMarvelous == “Y”
else:
print(“Aha! You’re Captain Marvel! Hi!”)

print("Answer these questions and let’s find out.\n")
print("Please use Y or N for yes and no.\n")

likeHangingaround = input("Do you like hanging around? ").lower()
if likeHangingaround == "y":
  print("Then you're Spider-man!")
else:
  print("Then you’re not Spider-man!")

likeGravellyvoice = input("Do you have a ’gravelly’ voice? ").lower()
if likeGravellyvoice == "y"
  print("Then you're Korg!")
else:
  print("Aww, then you’re not Korg")

likeMarvelous = input("Do you feel Marvelous? ")
if likeMarvelous == "y"
  print("Aha! You’re Captain Marvel! Hi!")
else:
  print("Then I don't know who you are.")

Notes:

  • Used a space after input prompt for a little bit nicer formatting (in my opinion)
  • Removed redundant print() statements at beginning
  • Fixed weird double quote issues
  • Added else statements (You can’t just have nothing there, that’s not how python does things)
1 Like

Thank you. Yours is working.

That should fix all errors

Welcome to replit ask @ThoushiqNaresh Hope you enjoy your time here.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.