8.0 Omitting Indices



Hi! i really want to understand this, i hope someone can explain the logic, would be great

to_five = ['A', 'B', 'C', 'D', 'E']
print to_five[:2]
# prints ['A', 'B']


Hi! It just prints slice of your list from very beginning till item with index 2 (not included)


its a list slice, starting at zero (default) increasing with steps of +1 (default) for values lesser then 2 (stop value):

prin to_five[0:2:1]


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.