O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

4-10. Slices:

From

Cover of Python Crash Course

Note

foods = ['pizza', 'burger', 'cake', 'coke', 'taco', 'burrito', 'meat ball', 'ice cream']
print("first three foods")
print(foods[:3])
print("last three foods")
print(foods[-3:])
print("three foods from middle of list")
print(foods[len(foods)/2 - 1 : len(foods)/2 + 2])