[Tutor] User Input List and Sort

kubota2550 at gmail.com kubota2550 at gmail.com
Wed Feb 14 22:05:38 CET 2007


Every example of a list that I've seen involves working with, sorting, etc
pre-populated list.  How can I create a list where the user inputs a string
of numbers and then sorts it?

I've tried:

print "Input list separated by commas"
lst=[raw_input()]
print lst
print len(lst)
lst.sort()
print lst

It appears to accept the input and will print the list but the length of the
list is wrong and it doesn't sort, leading me to believe that it is seeing
the input as 1 large input instead of separate numbers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070214/830ca889/attachment.html 


More information about the Tutor mailing list