0
私はPythonには新しく、この作業を行う方法を理解できません。Python IDLE 3.5基数10のint()のリテラルが無効
# My First Python Game Thing
# Aka Endless Walking Simulator
game_temp1 = True
def choiceroom_thing1():
while game_temp1:
directionchoice = input('L(left)R(Right)B(Backwards)F(Forwards)')
direction = int(directionchoice)
if direction in ['L', 'R','B', 'F']:
game_temp1 = False
if direction == "L":
print ('You went Left!')
if direction == "R":
print ('You went Right!')
if direction == "B":
print ('You went Backwards!')
if direction == "F":
print ('You went Forwards!')
game_temp1 = True
room_count = room_count + 1
choiceroom_thing1()
print ('Hello Jeff...')
print ('Heres my first game')
print ("Adventure Game")
input("Press Any Key To Continue...")
room_count = 1
while game_temp1:
directionchoice = input('L(left)R(Right)B(Backwards)F(Forwards)')
direction = int(directionchoice)
if direction in ['L', 'R','B', 'F']:
game_temp1 = False
if direction == "L":
print ('You went Left!')
if direction == "R":
print ('You went Right!')
if direction == "B":
print ('You went Backwards!')
if direction == "F":
print ('You went Forwards!')
game_temp1 = True
room_count = room_count + 1
choiceroom_thing1()
そして、私はそれを実行したとき、私はこのエラーを取得する:
は、ここに私のコードです(他の回答が私を助けにはなりません)。
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/PythonProjects/Blah From Book.py", line 27,
line 27, in <module>
direction = int(directionchoice)
ValueError: invalid literal for int() with base 10: ':'
コードを修正してもらえますか?
あなたが入力として手紙を求めている、それは一体、あなたが 'int'を呼び出しているのはなぜ' int' – gamda
に変換することはできませんユーザーに 'L'、' R'、 'B'、または' F'を入力するように頼んだのですか? – user2357112
それでintを置き換えるものは何ですか? –