I'd like to remove white spaces before & after each word in a list
with open(r"C:\filelocation") as f:
lines = f.readlines()
for i in lines:
i = i.strip()
i= i.split(",")
When I print my list, I get the following
['46', 'Celsius ']
['42', ' Celsius ']
['93', ' Fahrenheit ']
I tried i = i.strip() & it doesn't work for my list.
source https://stackoverflow.com/questions/76503747/strip-function-not-working-in-a-list-in-python
Comments
Post a Comment