I can't seem to fix this problem with if, elif and else statements. it seems like they are getting ignored when an incorrect value is inserted. Also is there a way to loop back to specific line of code instead of ending the program?
import sys
Name = raw_input ("What is your name?\n")
if Name.isalpha() == False:
"Your name must only contain letters from the alphabet\n"
sys.exit()
Gender = raw_input ("What is your gender? (Male/Female)\n")
if Gender == "Male" or "Female":
pass
else:
print "Invalid gender"
sys.exit()
print "Your name is " + Name + " and you are a " + Gender + "."
Aucun commentaire:
Enregistrer un commentaire