Y.G. Bae (30) [Avatar] Offline
#1
Hello.

To follow the explanation in the above paragraph, I feel that the example needs two more statements as below:
moby_text = moby_text.replace(",", "")     #D Removes commas
moby_paragraphs = moby_text.split("\n\n")


Hence, the example would be as the following:

>>> moby_text = open("moby_01.txt").read()     #A reads all of file as a single string
>>> moby_text = moby_text.lower()              #B Makes everything lower case
>>> moby_text = moby_text.replace(".", "")     #C Removes periods
>>> moby_text = moby_text.replace(",", "")     #D Removes commas
>>> moby_paragraphs = moby_text.split("\n\n")
>>> moby_words = moby_paragraphs[1].split()
>>> print(moby_words)
['there', 'now', 'is', 'your', 'insular', 'city', 'of', 'the', 'manhattoes', 'belted', 
'round', 'by', 'wharves', 'as', 'indian', 'isles', 'by', 'coral', 'reefs--commerce', 
'surrounds', 'it', 'with', 'her', 'surf', 'right', 'and', 'left', 'the', 'streets', 
'take', 'you', 'waterward', 'its', 'extreme', 'downtown', 'is', 'the', 'battery', 
'where', 'that', 'noble', 'mole', 'is', 'washed', 'by', 'waves', 'and', 'cooled', 
'by', 'breezes', 'which', 'a', 'few', 'hours', 'previous', 'were', 'out', 'of', 
'sight', 'of', 'land', 'look', 'at', 'the', 'crowds', 'of', 'water-gazers', 'there']


Thank you.

Best regards,
Y.G.
naomi.ceder (104) [Avatar] Offline
#2
Hi,

Yes, you are quite right! Thanks for catching that and letting me know!

Cheers,
naomi
Y.G. Bae (30) [Avatar] Offline
#3
Thank you for your reply. smilie To be greedy, as an afterthought, I guess I could have replaced “—“ as well. smilie
naomi.ceder (104) [Avatar] Offline
#4
Agreed. But once you start adding a number of characters, it then becomes easier to use the
.translate()
method... smilie
Y.G. Bae (30) [Avatar] Offline
#5
Cool! There are a lot to learn! smilie

Best regards,
Y. G.