def daenerys():
Name = raw_input("Who goes there?")
if ("Daenerys of the House Targaryen, the First of Her Name, The Unburnt, Queen of the Andals, the Rhoynar and the First Men, Queen of Meereen, Khaleesi of the Great Grass Sea, Protector of the Realm, Lady Regnant of the Seven Kingdoms, Breaker of Chains and Mother of Dragons"):
print("Welcome, Daenerys.")
elif ("DHTFHNUQARFMQMKGSPRLRSKBCMD"):
print("Welcome, Daenerys.")
elif ("Dany"):
print("Dany who?")
else:
print("Move along, now")
daenerys()
答案 0 :(得分:0)
您甚至都没有检查Name变量。你应该做
def daenerys():
Name = raw_input("Who goes there?")
if (Name == "Daenerys of the House Targaryen, the First of Her Name, The Unburnt, Queen of the Andals, the Rhoynar and the First Men, Queen of Meereen, Khaleesi of the Great Grass Sea, Protector of the Realm, Lady Regnant of the Seven Kingdoms, Breaker of Chains and Mother of Dragons"):
print("Welcome, Daenerys.")
elif (Name == "DHTFHNUQARFMQMKGSPRLRSKBCMD"):
print("Welcome, Daenerys.")
elif (Name == "Dany"):
print("Dany who?")
else:
print("Move along, now")
daenerys()
这实际上将检查变量Name
是否等于字符串。