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.
str(lst1)to see what the problem is.lst1[0]instead.lst1to a string in the first place? It contains a string as the element, use that.