Why the input function fails in returning result by a basic script?

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…

MY CODE:

name = 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>"

Thanks in advance!

Are you doing this in Rhino? I don’t think the Rhino command editor knows what to do with input.

In Rhino/Python if you want to ask the user for a string you would import the rhinoscriptsyntax module and then use GetString()

import rhinoscriptsyntax as rs
name = rs.GetString('What is your name?')
print(name)

Hi Flora,

The input() function (cf. documentation) is from Python 3 and reads user input from a command line or terminal. In Rhino, you should use what @Helvetosaur proposes above.
Rhino 7 also still uses IronPython 2.7, so you should use print "This and that", instead of the print() function from CPython 3.

Let me have a test, thank you!
I read the PDF for learning it. Seems the process is manipulated in a window that opened by rhino. Python, So I just write and test there.
Let me make sure of the platform first.
THX

Hi, Diff.
How are you! Long time I am away from here, LOL. Happy new year!
Thanks for your suggestion.
Upon all your help I think I can handle the problem now. Let me try.:smiley:

Thanks, to you, too. I remember the Chinese New Year from when I was in Singapore 5 years ago around this time of the year.

Yep. Actually tmr is the last day of celebrating the coming of new year, another get-together day:D
SG has similar tradition as Asian ppl share some common festivals,LOL

diff-arch via McNeel Forum <notifications@mcneel.discoursemail.com> 于 2023年2月5日周日 上午1:21写道: