Respuesta :

Answer:

order by

votes

Up vote

0

Down vote

Accepted

You could use:

# Open the file

file = open('example.txt', 'r')

# Create your results

res = []

# Edited from https://www.geeksforgeeks.org/python-program-to-read-character-by-character-from-a-file/

while 1:

# read by character

char = file.read(1)

# If youre out of characters

if not char:

break

# If not, add the character to the list, but don't include breaking spaces

elif char != '\n':

res.append(char)

# Close your file object

file.close()

# Print out the results

print(res)