当我给出这个选项时,它会自动去pokemart而不是高高的草丛。
place_1 = input("Where do you want to go?")
if place_1 == "pokemart":
print("You go to the pokemart")
print("Seller: Hello! Welcome to the pokemart!")
print("Seller: Hi! I work at a POKEMON MART. It's a convenient shop, so please visit us in VIRIDIAN CITY. I know, I'll give you a sample! Here you go!")
print("You get 3 potions and 3 pokeballs")
print("Customer: See those ledges along the road? It's a bit scary, but you can jump from them. You can get back to PALLET TOWN quicker that way.")
pokemart_1 = input("Would you like to buy a potion or a pokeball?")
if pokemart_1 == "potion":
print("You spend 100 pokedollars on a potion")
money = money - 100
print(money)
elif pokemart_1 == "pokeball":
print("You spend 100 pokedollars on a pokeball")
money = money - 100
print(money)
else:
print("You go to the tall grass")
我希望有这个选择。
您的缩进已关闭。由于第二部分未在第一个条件块内缩进,因此无论
place_1
的值如何,它都会运行。
place_1 = input("Where do you want to go?")
if place_1 == "pokemart":
print("You go to the pokemart")
print("Seller: Hello! Welcome to the pokemart!")
print("Seller: Hi! I work at a POKEMON MART. It's a convenient shop, so please visit us in VIRIDIAN CITY. I know, I'll give you a sample! Here you go!")
print("You get 3 potions and 3 pokeballs")
print("Customer: See those ledges along the road? It's a bit scary, but you can jump from them. You can get back to PALLET TOWN quicker that way.")
pokemart_1 = input("Would you like to buy a potion or a pokeball?")
if pokemart_1 == "potion":
print("You spend 100 pokedollars on a potion")
money = money - 100
print(money)
elif pokemart_1 == "pokeball":
print("You spend 100 pokedollars on a pokeball")
money = money - 100
print(money)
else:
print("You go to the tall grass")