Add each character from each line of a text file, to a list in Python

Liam G

So I want to read each character (separated by spaces) of each line of a text file and add them to a seperate index of a list for each line.

file = open("theTextFile.txt", 'r+')
pal = []

words = file.split(' ')
pal.append(words)

print(pal)
split_line(file)

The text file has a single character separated by a space for each line. The editor wouldn't allow for my punctuation from the text file, but below is an example of what it looks like.

r o t o r

r a c e c

Liam G

This is what I did to solve my issue:

lines = open('theTextFile.txt','r')

secondList = []
for line in lines:
    line = line.split()
    secondList.append(line)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

add a character to each line in a text file php

From Dev

add a character to each line in a text file php

From Dev

How to efficiently read the first character from each line of a text file?

From Dev

Print the line number of a text file for each word from a list in python 3 without importing anything

From Dev

add "text" automatically after each line in a list

From Dev

python - How to extract strings from each line in text file?

From Dev

Get each word from a line in a text file

From Dev

Count values for each line in text file python

From Dev

printing the output for each line from a file in python

From Dev

python choose randomly from each line of a file

From Dev

how to extract particular string with special character from each line of a file

From Dev

how to extract particular string with special character from each line of a file

From Dev

Read lines from file, iterate over each line and each character in that line

From Dev

Wrap each line in a text file in apostrophes and add comma to end of lines

From Dev

Add some text to each line of txt file and pass to wget

From Dev

Adding a character at beginning and at the end of each line in a text

From Dev

Adding a character at beginning and at the end of each line in a text

From Dev

how to add a character at the beginning of each line in Richtextbox

From Dev

Reading lines from a text file and creating a text file for each name on each line

From Dev

Reading lines from a text file and creating a text file for each name on each line

From Dev

in Notepad ++, add the text of each line at the end of the line

From Dev

How can I read the first line from every text file in a specific directory and add each line to a listbox in a C# WPF app?

From Dev

Comparing each line in txt file to another text file in each line

From Dev

Printing out each line (from file) with line number python

From Dev

Reading only first character of each line in file

From Dev

add same string to each line in list using python 2

From Dev

Putting each line from a text file into an array C#

From Dev

remove first char from each line in a text file

From Dev

remove current path portion from each line in a text file

Related Related

  1. 1

    add a character to each line in a text file php

  2. 2

    add a character to each line in a text file php

  3. 3

    How to efficiently read the first character from each line of a text file?

  4. 4

    Print the line number of a text file for each word from a list in python 3 without importing anything

  5. 5

    add "text" automatically after each line in a list

  6. 6

    python - How to extract strings from each line in text file?

  7. 7

    Get each word from a line in a text file

  8. 8

    Count values for each line in text file python

  9. 9

    printing the output for each line from a file in python

  10. 10

    python choose randomly from each line of a file

  11. 11

    how to extract particular string with special character from each line of a file

  12. 12

    how to extract particular string with special character from each line of a file

  13. 13

    Read lines from file, iterate over each line and each character in that line

  14. 14

    Wrap each line in a text file in apostrophes and add comma to end of lines

  15. 15

    Add some text to each line of txt file and pass to wget

  16. 16

    Adding a character at beginning and at the end of each line in a text

  17. 17

    Adding a character at beginning and at the end of each line in a text

  18. 18

    how to add a character at the beginning of each line in Richtextbox

  19. 19

    Reading lines from a text file and creating a text file for each name on each line

  20. 20

    Reading lines from a text file and creating a text file for each name on each line

  21. 21

    in Notepad ++, add the text of each line at the end of the line

  22. 22

    How can I read the first line from every text file in a specific directory and add each line to a listbox in a C# WPF app?

  23. 23

    Comparing each line in txt file to another text file in each line

  24. 24

    Printing out each line (from file) with line number python

  25. 25

    Reading only first character of each line in file

  26. 26

    add same string to each line in list using python 2

  27. 27

    Putting each line from a text file into an array C#

  28. 28

    remove first char from each line in a text file

  29. 29

    remove current path portion from each line in a text file

HotTag

Archive