Issue
I have a list
list = ['1,2,3,4,5,6,7']
I want my list as under:
desire output = [1,2,3,4,5,6,7]
how to get this, i read other similar answer where strip method used. i had tried strip but strip method not work with list, it work with strings.
'list' object has no attribute 'strip'
Solution
What you have is a list
with a single str
element. To get the list you want, try:
lst = ['1,2,3,4,5,6,7']
>>> list(map(int, lst[0].split(",")))
Answered By - not_speshal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.