How to remove leading and trailing zeros from a list of strings in Python

1 Answer

0 votes
lst = ['0000478364000000', '000843900', '00123470', '010']

lst = [item.strip('0') for item in lst]

print(lst) 



'''
run:

['478364', '8439', '12347', '1']

'''

 



answered Jul 19, 2022 by avibootz

Related questions

1 answer 153 views
1 answer 127 views
2 answers 173 views
1 answer 123 views
...