私のコードは、無効な文字識別子を持っていると言っています。識別子に無効な文字があります。4
import random
answer1 = ("Absolutely!")
answer2 = ("No way Pedro!")
answer3 = ("Go for it tiger.")
input("Welcome to the Magic 8 Ball game and use it to answer your questions...")
question = int(input("Ask me for any advice and I’ll help you out. Type in your question and then press Enter for an answer."))
print("shaking.... \n" * 4)
choice = random.randint(1,3)
if choice == 1:
answer = Answer1
elif choice == 2:
answer = Answer2
else:
answer = Answer3
print(answer)
インデントを修正してください。これはPythonでは非常に重要です。 – cdarke
そして、 'answer1'と' Answer1'は二つの*異なる*識別子です。 –
ユーザが2番目の 'input()'に何も入力しないと()、 'int()'変換は 'ValueError'をスローします。例外処理が必要なのかもしれません。 –
cdarke