How do I convert from a string to a list? I want my string to be exactly the same, but as a list. Is that possible in python? If so, how do I do so?
Asked
Active
Viewed 165 times
1
-
can provide an example with sample data? – Rajat Mishra Jan 12 '18 at 07:26
-
2`list('test')` or `list(my_str_var)` should be enough I think ;) – mic4ael Jan 12 '18 at 07:27
1 Answers
0
Try this one :
string_ex = "define here your string"
string_ex.split()
and
string_ex = "your string"
list(string_ex)
I hope it will help you
Also see this one it's help you : https://stackoverflow.com/a/8266559/5747242

Jignasha Royala
- 1,032
- 10
- 27
-
-
can you define in details with example? @DavidTECDavidGames999 – Jignasha Royala Jan 12 '18 at 08:50
-
A list that has been written as a string, example: [[192, 0], [168, 1]] that then is made back into a string. the problem that I found with what you linked me was that the integers were written as strings. Since how I want it, it saves the entire list into a file as a string. So, what I want, A list that can be converted into a string and back that can be saved in a file through python – DavidTEC DavidGames999 Jan 12 '18 at 10:08
-
I am not clearly understand can you define what your input and what you want output @DavidTECDavidGames999 – Jignasha Royala Jan 12 '18 at 10:37
-
What I want is a file that is made with python to contain a list that can be used to define variables that can also be changed. Really just a list in a file that can be edited from a python script. – DavidTEC DavidGames999 Jan 12 '18 at 11:22
-
that is not relevant to your question can you please ask new question or edit this one Thank you!! @DavidTECDavidGames999 – Jignasha Royala Jan 12 '18 at 12:30