Python の初心者として、私が取り組んでいることの 1 つは、文字ジェネレーターです。一緒に投げたコードからわかるように、私はレースの選択をしようとしています。
########Race########
#.racechoose (label)
hero_race = input("What is your hero's race? (Human / Elf / Dwarf / Orc) Don't forget to capitalize! ")
if hero_race == 'Human':
print ("Humans are well-rounded, average characters. They have a bonus of + 1 to Speed and + 1 to Int.")
yn = input ("Do you want to be a Human (Y/N)? ")
if yn == 'y' or yn == 'Y':
profile['Race'] = "Human"
print ("Your hero", profile['Name'], "is a human.")
else:
#goto racechoose
elif hero_race == 'Elf':
print("Elves are very fast, and they have a bonus of + 2 to Speed.")
yn = input("Do you want to be an Elf? (y/n) ")
if yn == 'y' or yn == 'Y':
profile['Race'] = "Elf"
print("Your hero ", profile['Name'], "is an Elf.")
else:
#goto racechoose
elif hero_race == 'Dwarf':
print("Dwarves are small, but strong. Dwarves get a bonus of + 2 Muscle.")
yn = input("Do you want to be a Dwarf? (Y/N) ")
if yn == 'y' or yn =='Y':
profile['Race'] = 'Dwarf'
print("Your hero ", profile['Name'], "is a Dwarf.")
else:
#goto racechoose
else: #orc
print("Orcs are brute muscle. Orcs get a bonus of + 3 to Muscle, but - 1 to Int.")
yn = input("Do you want to be an Orc? (Y/N) ")
if yn == 'y' or yn == 'Y':
profile['Race'] = 'Orc'
print("Your hero ", profile['Name'], "is an Orc.")
else:
#goto racechoose
goto と label のコメントは無視してください - 最近 blitzbasic の使用をやめたばかりで、現在 Python の label と goto コマンドを探しています。
とにかく、elif のヒーロー レース Elf の行で "Expected an indented block" が表示されます。このコードを正しくインデントする方法を知りたいです。ありがとう!