Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: MacPython basics - how to use input command?  (Read 3236 times)

ovalking

  • 128 MB
  • ****
  • Posts: 217
  • new to the forums
MacPython basics - how to use input command?
« on: April 03, 2024, 08:29:59 AM »

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'
Logged

Protools5LEGuy

  • Staff Member
  • 2048 MB
  • ******
  • Posts: 2790
Re: MacPython basics - how to use input command?
« Reply #1 on: April 03, 2024, 08:54:51 AM »

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
Logged
Looking for MacOS 9.2.4

DrNo7

  • 64 MB
  • ****
  • Posts: 98
Re: MacPython basics - how to use input command?
« Reply #2 on: April 03, 2024, 09:51:12 PM »

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.
Logged
Ti 1 GHz / 1 GB / FW SSD / Airport Extreme PCMCIA (triple boot)
Alu 12 1.5GHz / 1.5 GB / 256 GB mSata SSD (dual boot for now)

ovalking

  • 128 MB
  • ****
  • Posts: 217
  • new to the forums
Re: MacPython basics - how to use input command?
« Reply #3 on: November 11, 2024, 07:10:46 AM »

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
Logged

Bolkonskij

  • Staff Member
  • 256 MB
  • *****
  • Posts: 297
    • Cornica.org
Re: MacPython basics - how to use input command?
« Reply #4 on: November 12, 2024, 11:26:34 PM »

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 ... :-)
Logged

Jubadub

  • 256 MB
  • *****
  • Posts: 447
  • There is no Mac in OS X
Re: MacPython basics - how to use input command?
« Reply #5 on: November 16, 2024, 03:48:07 AM »

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 ... :-)

An online converter for Python 3.x to (Mac)Python 2.3.5 & earlier could be cool to have, if we can locate such a thing. :)


EDIT: Version number correction.
« Last Edit: November 17, 2024, 12:28:57 AM by Jubadub »
Logged
Pages: [1]   Go Up

Recent Topics