I have a string in the file, for example, 'HELLO', and I need to convert the string in list by characters, 'H', 'E', 'L', 'L', 'O'. How to implement it?
Asked
Active
Viewed 40 times
1 Answers
0
Assuming your file is called myfile.txt
:
In [1]: with open('myfile.txt', 'r') as myfile:
...: mystring = myfile.read()
...: print(list(mystring))
...:
['H', 'E', 'L', 'L', 'O']

Ashish Acharya
- 3,349
- 1
- 16
- 25