0
Я новичок в python, и я не могу понять, как это сделать, он просто не работает. (И другие ответы не поможет мне)Python IDLE 3.5 недействительный литерал для int() с базой 10
Вот мой код:
# 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' – gamda
Какого черта ты звонишь' int' когда вы попросили пользователя ввести 'L',' R', 'B' или' F'? – user2357112
Что я могу заменить int тогда? –