[Tutor] Printing list in a Column
Alan Gauld
alan.gauld at btinternet.com
Fri Aug 31 09:58:50 CEST 2012
On 31/08/12 02:12, Ashley Fowler wrote:
> Can anyone help me edit this code below to return the list in the form
> of a column instead of a row?
>
> def printList():
> list1 = input("Insert a list")
> list = [list1]
> print (list)
First you need to convert the string that your user types into a list of
individual entries. At the moment your list consists of a single string
so the column will only have a single line.
You probably want to look at the split() method of strings.
Alternatively you could write a loop which reads each entry individually
from the user.
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list