Here is one possible implementation of your project. *Code:* #Dont use list as a variable name, its one of the reserved words. mylist = []
#realize any values captured here are strings x = raw_input('Enter num or text: ') mylist.append(x) x = raw_input('Enter num or text: ') mylist.append(x) #output the type of objects you've entered (hint: they'll always be strings.. ;) print type(mylist[0]) print type(mylist[1]) #print the list of items for i in mylist: print i *When you run the program:* Enter num or text: 27 Enter num or text: Eric <type 'str'> <type 'str'> 27 Eric On Fri, Feb 27, 2009 at 10:19 AM, Network Administrator < administrador.de....@gmail.com> wrote: > I am beggining to learn Python and I appreciate if you help me with this: > > "I want a piece of a program to request the user to input "elements" > (numbers, text, etc) and store them into a list. Then, I want to display all > the elements one-per-line." > > I started using this code: > > #!/usr/bin/env python > ##################### > # This function fills any given list > # and display its content. > # > x = 0 # Variable "x" initiallized to zero, just > because Python required it > while (x != 't2' ): # On user's input "t2", no more input must be > required > list = [] # I start a zero-elements list > x = raw_input('Enter your number or text: ') # Software > asks for user's input. > > list.append(x) > # User's input is append to the list "list" > > for x in list: # It asks to enter the list and... > print x # print their elements. > > Unfortunately, this code fails to do what I expect. I notice that user's > input is not being append to the list, so, when I require to print the > elements of the list only "t2" is displayed. I don't know how to append > elements to a list on user's input. > > I appreciate your clearence. > > Regards, > > > Will. > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor