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 - [email protected]
http://mail.python.org/mailman/listinfo/tutor