Mac OS 9 Discussion > Development & Programming
MacPython basics - how to use input command?
ovalking:
Got the chance to do some training, and thought I'd have a look at Python.
Using MacPython 2.2.3, but got stuck in the first lesson. Where am I going wrong?
'name = input("What is your name?\n")'
When I run this it requests my input. So I enter ovalking and it responds with:
'NameError : name ovalking is not defined'
Protools5LEGuy:
In Sinclair Basic alfanumeric strings end with the dólar símbol. And numeric dont have it.
No idea if you need to define Class or something similar.
Good luck
DrNo7:
Hi ovalking,
If you reproduced the line as-is, the single-quotes should be removed. This will make the line assign the input string into a variable.
If your script does not have the outer single-quotes, then I would suggest you check the Python 2.2.3 documentation as the inout method then may have some oddities more recent versions of Python straightened out.
ovalking:
I've not done much more on this because of command differences between my training source and MacPython.
However I did work out the answer to my question!
You have to use 'raw_input' instead of 'input'.u
Bolkonskij:
Given Python's popularity it might be worth to gather all good documentary on Python 2.x and MacPython somewhere as it is likely to drown in a sea of Python 3.x tutorials and getting hard to find. Precisely to help with the kind of problems you've been encountering. Creating a dedicated MacPython page accessible from old machines sounds like a great hobby project ... :-)
Navigation
[0] Message Index
[#] Next page
Go to full version