I'm trying to strip a colon (':') from every string in a list of 1000 strings. So far, I've tried using a map function with a rstrip and just a strip function but have had no luck. I also tried a simpler for loop function as seen below.
I'm not getting any errors, but when I try to print char it doesn't remove the colons
char = ['g:', 'l:', 'q:'] #in my actual code there are 1000 strings
for i in range(0,999):
char[i].strip(':')
and also
for i in range(0,999):
char[i].rstrip(':')
char[i].strip(':')
creates a new string object. – jonrsharpechar[:] = [ch.rstrip(':') for ch in char]
. See How to modify list entries during for loop? – martineau