[Tutor] how to take user input to form a list?

Bill Mill bill.mill at gmail.com
Sun Nov 14 03:16:25 CET 2004


Lin,

In [6]: count = 0

In [7]: nums = []

In [8]: while count < 4:
   ...:     n = input('Number: ')
   ...:     nums.append(n)
   ...:     count += 1
   ...:
Number: 1
Number: 2
Number: 3
Number: 4

In [9]: print nums
[1, 2, 3, 4]




On Sun, 14 Nov 2004 09:59:54 +0800, Lin Jin <jinlin555 at msn.com> wrote:
> hello,all:
>   if i want to make a function that takes user input to form a list,how i
> could do that?
> it's run like:
> >>>Enter 4 letters:
> >>>a
> >>>b
> >>>c
> >>>d
> >>>[a,b,c,d]
> and i write a code like this which is not working:
> def list(let1,let2,let3,let4):
>    let1,let2,let3,let4=raw_input("enter 4 letters:")
>    list=[let1,let2,let3,let4]
>    print list
> 
> anyone could help me on this? thx
> 
> _________________________________________________________________
> 免费下载 MSN Explorer:   http://explorer.msn.com/lccn/
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list