So I have a list and a couple of string in it. I just want to remove the first 7 characters from each of the strings. How do I do that?
lst = ["1234567something", "1234567smthelse"]
for i in lst:
i [7:] you are not actually editing the element of the list, you are just computing a new string, without the first 7 characters, and not doing anything with it.
You can do this instead :
>>> lst = [e[7:] for e in lst] >>> lst ['something', 'smthelse']
This will loop on the elements of your array, and remove the characters from the beginning, as expected.