I keep getting a syntax error on the second else:
in this code. I've tried counting spaces, double checking braces, etc. I can't figure out what's wrong. Am I missing something?
if cclass == "wizard" or cclass == "cleric":
level = input("What is your level of {}?".format(character_class))
if (int(level)>=1 and int(level)<=20):
print ("Welcome {}, {} of level {}".format(name, character_class, level)
else:
input("That level is out of range. Press enter to exit.")
sys.exit()
else:
input("You do not appear to be a character class that uses a grimoire.")
sys.exit()
You are missing a closing parenthesis on the print()
call:
print ("Welcome {}, {} of level {}".format(name, character_class, level)
# ^ ^ ^^?
# | \-------- closed ----------/ |
# \-------------------------- remains open -----------------------/
Python cannot see where this statement ends now and throws a syntax error when it then finds an else
statement instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.