jeudi 5 novembre 2015

How to return the contents of the file as a list of messages

The parameter represents a message file that is already open for reading, and which contains one message per line.

Read and return the contents of the file as a list of messages, in the order in which they appear in the file. Strip the newline from each line.

def read_messages(file):
    """
    """
    message = []
    for line in file:
        new_line = line.strip()
        message.append(new_line)
    return message

well, I know this is not the correct answer but I have no idea how can I fix it.

Aucun commentaire:

Enregistrer un commentaire