[Python] Python code to create list from a file [closed]

Discussão em 'Python' iniciado por Stack, Dezembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    I have a dictionary file.txt, with 3 - 5 words in each line.

    Like:

    apple ball back hall
    hello bike like


    I need a python code to put all these words into a list before any other coding occurs.

    My idea is to read the file line-by-line, and use split(), and list.append() functions, but I don't seem to sort it out. Can anyone help?

    Edited: Said it the wrong way, sorry!

    Continue reading...

Compartilhe esta Página