私はコーディングの初心者ですが、現在はRPGを作っています。コードを実行すると、上記のエラーが表示されます。私にエラーを出す部分はprint("You are on " + floors[currentRoom] + ". You find " + floorsFeature[currentRoom])
です。私の推測では、フロア、フロアフィーチャ、およびcurrentRoomsに何か問題があるはずです。私は初心者なので、エラーの意味が分かりません。誰か簡単に説明できますか?"リストのインデックスはタプルではなく整数またはスライスでなければなりません"エラー
print("You are finally a Pokemon trainer! Today, you have gotten your very first Pokemon, a Bulbasaur!")
name = input("What will you name your Bulbasaur? ")
print("Unfortunately, " + name + " doesn't seem to obey or like you...")
print("You try to be friendly to " + name + ", but it just won't listen...")
print("As " + name + " was busy ignoring you, something seems to catch its attention and it runs off!")
print("You chase after " + name + ", but it's too fast! You see it running into an abandoned Pokeball Factory.")
print("You must explore the abandoned Pokeball Factory and find " + name + " before something happens to it!")
print()
print("You may input 'help' to display the commands.")
print()
gamePlay = True
floors = [['floor 1 room 1', 'floor 1 room 2', 'floor 1 room 3', 'floor 1 room 4'],['floor 2 room 1', 'floor 2 room 2', 'floor 2 room 3', 'floor 2 room 4', 'floor 2 room 5'],['floor 3 room 1,' 'floor 3 room 2', 'floor 3 room 3'],['floor 4 room 1', 'floor 4 room 2']]
floorsFeature = [['nothing here.', 'nothing here.', 'stairs going up.', 'a Squirtle.'],['stairs going up and a pokeball.', 'a Charmander.', 'a FIRE!!!', 'stairs going down.', 'a pokeball.'],['stairs going down.', 'a door covered in vines.', '2 pokeballs!'],['your Bulbasaur!!!', 'an Eevee with a key tied around its neck.']]
currentRoom = [0][1]
pokemonGot = []
count = 0
bagItems = []
countItems = 0
while gamePlay == True:
print("You are on " + floors[currentRoom] + ". You find " + floorsFeature[currentRoom])
move = input("What would you like to do? ")
while foo(move) == False:
move = input("There's a time and place for everything, but not now! What would you like to do? ")
if move.lower() == 'left':
if currentRoom > 0:
currentRoom = currentRoom - 1
print("Moved to " + floors[currentRoom] + ".")
else:
print("*Bumping noise* Looks like you can't go that way...")
elif move.lower() == 'right':
if currentRoom < len(floors) - 1:
currentRoom = currentRoom + 1
print("Moved to " + floors[currentRoom] + ".")
else:
print("*Bumping noise* Looks like you can't go that way...")
elif move.lower() == 'help':
print("Input 'right' to move right. Input 'left' to move left. Input 'pokemon' to see what Pokemon are on your team. Input 'bag' to see the items you are carrying. Input 'help' to see the commands again.")
elif move.lower() == 'pokemon':
if count == 0:
print("There are no Pokemon on your team.")
else:
print("The Pokemon on your team are: " + ", ".join(pokemonGot) + ".")
elif move.lower() == 'bag':
if countItems == 0:
print("There are no items in your bag.")
else:
print("The items in your bag are: " + ", ".join(bagItems) + ".")
print()
currentRoom = [0] [1] このコードは正しいですか?ちょうど2倍のチェック – elanor
「フロア3の部屋1」、「フロア3の部屋2」、...でカンタが引用符から外れるはずです。 – Adirio