-4

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!

1 Answers1

1

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]
Riccardo Bucco
  • 13,980
  • 4
  • 22
  • 50