Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
567 B
7
Indexable
Never
import string
def read():
    f = open("gruffalo.txt", "r")
    word = ""
    while True:
        character = f.read(1)
        if not character:
            break
        if character in string.ascii_letters:
            word += character

        elif character in string.punctuation:
            if character == "'":
                word += character

            else:
                print(word)
                print(character)
                word = ""

        else:
            print(word)
            word = ""

    f.close

read()