NOTE - This is NOT the same as all the other questions/answers about this - Read carefully [and remember to test before you reply if you're not 100% certain it works]:-
I do NOT want to create a new reference to an object that is a copy of my original one, minus the last character, I want to actually remove the last character. See this example:-
def remo(dat):
for line in dat:
line=line[:-1] # THIS LINE IS WRONG. What do I put here?
print("new line is:"+line)
return dat
s=['fred','wilma']
n=remo(s);
print(s)
print(n)
Running the above, as you can see, returns the wrong answers:-
python demo.py
new line is:fre
new line is:wilm
['fred', 'wilma']
['fred', 'wilma']
What is the real way to actually remove the last character?