B
brad
Is this the correct way to slice the last 4 items from a list?
x = [1,2,3,4,5,6,7,8,9]
print x[-4:]
It works, but is it Pythonic?
x = [1,2,3,4,5,6,7,8,9]
print x[-4:]
It works, but is it Pythonic?
Is this the correct way to slice the last 4 items from a list?
x = [1,2,3,4,5,6,7,8,9]
print x[-4:]
It works, but is it Pythonic?
Is this the correct way to slice the last 4 items from a list?
x = [1,2,3,4,5,6,7,8,9]
print x[-4:]
It works, but is it Pythonic?
Is this the correct way to slice the last 4 items from a list?
x = [1,2,3,4,5,6,7,8,9]
print x[-4:]
It works, but is it Pythonic?
It's Pythonic. It's also unambiguous, unlike your specification, which
could be interpreted as 'chop off the last 4 items from a list' ...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.