read from user
Mikael Olofsson
mikael at isy.liu.se
Tue Nov 19 09:36:42 EST 2002
Hi Pål!
On Tue, 19 Nov 2002 15:22:11 +0100
"Pål Sindre Hiåsen" <sindrehi at c2i.net> wrote:
> Is there somthing i have to think about when i write code who ask for
> input from user?
> I tried this:
> antall = input('some instruction ') #read a int
> for i in range(10):
> L[i]= raw_input('write names ') #read string
>
> What is wrong??
Did you not get an error traceback? When I tried that in the interactive
shell, I got
Traceback (most recent call last):
File "<stdin>", line 2, in ?
NameError: name 'L' is not defined
after typing in the for loop. It simply tells you that there is no
variable called L. What you need to do is to initiate L as an empty list
before entering the loop.
HTH
/Mikael
-----------------------------------------------------------------------
E-Mail: mikael at isy.liu.se
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
/"\
\ / ASCII Ribbon Campaign
X Against HTML Mail
/ \
This message was sent by Sylpheed.
-----------------------------------------------------------------------
Linköpings kammarkör: www.kammarkoren.com
More information about the Python-list
mailing list