Trimming lists using a loop
Posted
by Vishal
on Stack Overflow
See other posts from Stack Overflow
or by Vishal
Published on 2010-06-16T16:34:28Z
Indexed on
2010/06/16
16:42 UTC
Read the original article
Hit count: 129
python
I have few lists like:
a = [1, 2, 3, 4, 5]
b = [4, 6, 5, 9, 2]
c = [4, 7, 9, 1, 2]
I want to trim all of them using a loop, instead of doing as below:
a[-2:]
b[-2:]
c[-2:]
I tried but got confused with pass by value or pass by reference fundamentals, looked into other questions as well but no help.
Thanks
© Stack Overflow or respective owner