[Tutor] Simple Python Problem

Alan Gauld alan.gauld at btinternet.com
Mon Sep 6 19:48:00 CEST 2010


"Keith Lucas" <kwl at aber.ac.uk> wrote

> What is wrong with the following, apparently almost straight out of 
> Python Programming
> by Michael Dawson?
>

You are using Python v2, the tutorial seems to be written for v3.
There are big diffeernces in syntax between them, v3 is NOT
backwards compatible with v2.

> # Get value.
> name = input("What is your name? ")

In v2 that would be

name = raw_input("What is your name")

> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit 
> (Intel)] on win32 Type
> "copyright", "credits" or "license()" for more information.
>>>> ================================ RESTART 
>>>> ================================
> What is your name? Keith

I think there is a trick in V2.7 to make it act more like v3 but 
someone
else will need to tell you what it is... :-)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list