我已经完成了while循环,开始时有一个输入,在1个不正确或正确的输出之后,循环结束了吗?任何提示或我所缺少的,对不起,转储大量代码
playgame = True
while playgame == True:
playgame = input("\nPlease enter choice\n [list, heroes, villains, search, reset, add, remove, battle, quit]:")
if playgame == "list" :
display_characters(character_list, 0)
elif playgame == "heroes" :
display_characters(character_list, 1)
elif playgame == "villains" :
display_characters (character_list, 2)
elif playgame == "search" :
print(" ")
name = input("Please enter name:")
find_character(character_list, name)
elif playgame == 'reset' :
print("")
name = input("Enter the name of the character: ")
print ("")
index = 0
result = -1
for character in character_list:
if character == value:
result = index
index += 1
if result == -1 :
print ("")
print (value, "is not found in character (heroes and villains) list.")
print ("")
else:
character_list[result].set_health(100)
print("")
print ("Successfully upadted", value, "health to 100")
print("")
elif playgame == "add\n" :
name = input("Enter the name of the character:")
print("")
secret_id = input ("Enter the secret identity of the character:")
print("")
hero = input ("Enter if the character is hero or villain [h/v]:")
print ('')
if hero == "h" :
is_hero = True
elif hero == "v" :
is_hero = False
if name in character_list:
print(name, "already exists in the character list")
add_character(character_list, name, secret_id, is_hero)
print ('')
elif playgame == "battle" :
print("")
do_battle(character_list, opponent1_pos, opponent2_pos)
elif playgame == "quit" :
print("\n\n-- Program terminating --\n")
playgame == False
else:
print("\nNot a valid command - please try again.")
playgame == True