Ambrosio Ambrosio - 1 year ago 124
Python Question

How do I truncate a list?

If I have a list and want to truncate it so it is no more than 100 items, how do I do this?

Answer Source

To modify the list in place (rather than make a shorter copy of the list), use:

del l[100:]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download