vendredi 4 juillet 2014

Converting list to columns and rows


Vote count:

0




My assignment is to take some data from a file called oliver.txt and put it into a variable and then put the first 100 words of the string in a list.


Then, for the first 100 words, we are supposed to print it out in rows containing only 6 words per row, and the column lengths is the length of longest word of that column plus 2 word space.


Also we have to then count the number of unique words for that 100 words and print those unique words out.


So I have done everything up to the columns and rows part and tried for a long time and got nowhere, hopefully someone here can help me. Here's what I have so far:



a_long_string = open('oliver.txt', 'r').read()

allwords = a_long_string.split()

first_hundred = allwords[0:100]




asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire