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'

11th Jul 2020, 1:07 PM
Baran Aldemir
Baran Aldemir - avatar
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()
11th Jul 2020, 1:13 PM
Мг. ĐšĐœĐ°ĐżđŸŒ 
Мг. ĐšĐœĐ°ĐżđŸŒ  - avatar