0
Why str.strip doesn't work properly?
python interpret the code line below: 'They bought a car, and a horse'.strip(".,").lower().split() like this: ['they', 'bought', 'a', 'car,', 'and', 'a', 'horse'] why str.strip do not remove ',' next to 'car'
3 Answers
+ 1
strip removes characters from the beginning and end of a string.
You can use str.replace() method
'They bought a car, and a horse'.replace(",","").lower().split()