I'm new to programming so I hope you could help me with this.
I have a list like below:
a_list = ['0,0,0,1,1,1,2,2,2,3,3,3,4,4,4']
How can I convert the list which is a string to float or int format?
Thanks in advance!
I'm new to programming so I hope you could help me with this.
I have a list like below:
a_list = ['0,0,0,1,1,1,2,2,2,3,3,3,4,4,4']
How can I convert the list which is a string to float or int format?
Thanks in advance!
Here is a possible solution:
list(map(int, a_list[0].split(',')))
Result:
[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]