1
a = input('name: ')
print('hello, ', a)

Запускаю ввожу строку и выдает ошибку NameError: name 'sadasd' is not defined

так тоже

a = str(input('name: '))
print('hello, ', a)
2

1 ответ 1

2

Судя по всему, вы запускаете этот скрипт в python2. В python3 все работает прекрасно. Если все же нужен python2, то код должен выглядеть так:

a = raw_input('name: ')
print 'hello, ', a

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.