Dear All:
I am learning the ‘input’ fuction by follow the intro book to write the script in command window, but it returns back a red message. It is weird to me as I just copy the script line from book to test, but without getting back a same answer as it is written in the book.
Here I type the sentence ‘CHUCK’ as written in the book.
Below it the sampe and what I typed in Pyton in rhino.
Could any professor tell me why this happens? It is very simple line that I didn’t expect to meet such problem…
I tested this command this time,
Message: name 'CHUCK' is not defined
Traceback:
line 1, in <module>, "C:\Users\Lenovo\AppData\Local\Temp\TempScript.py"
line 1, in <module>, "<string>"
Hi, Barry
Thanks for your suggestions!
Here are the problem, when I type ‘CHUCK’ when it requires an input, it show below:
MY CODE:
input('What is your name?')
print(name)
THE ERROR MESG IS HERE:
Message: name 'CHUCK' is not defined
Traceback:
line 1, in <module>, "C:\Users\Lenovo\AppData\Local\Temp\TempScript.py"
line 1, in <module>, "<string>"
What version of Python are you using?
In Python 3 this should indeed be simple and no problem, but in Python 2 and before input worked differently and raw_input did what input does nowadays.
Also, please copy your code instead of rewriting it, you probably forgot to start the first line with "name = ".
If you execute this as you’ve written it, you get name 'name' is not defined
Thanks Alvert!
My python is 3.11,
also, I edited in first post with 'name = ', emmm, seem not help at alll
I assume it maybe version problem?
name = input('What is your name?')
print(name)
Message: name 'chuck' is not defined
Traceback:
line 1, in <module>, "C:\Users\Lenovo\AppData\Local\Temp\TempScript.py"
line 1, in <module>, "<string>"