Any Idea when I do the split on list( after converting to string) I am not getting the first and the last elements in the list….
if __name__ =="__main__":
lst1= ['3 6 2 5'];
lst1=str(lst1);
a = [int(i) for i in lst1.split(' ') if i.isdigit()]
print(a);
Outputs
[6, 2]
What I am looking for is
[2,3,5,6]
I think its due to the split characters which it finds after the 3(first element), but not sure how to resolve it.
>Solution :
Try it.
lst1= ['3 6 2 5'];
a = [int(i) for i in lst1[0].split(' ') if i.isdigit()]
a.sort()
print(a)