# 使用列表中的一部分——切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])
print(players[1:4])
print(players[:4])
print(players[2:])
print(players[-3:])

# 遍历前三名运动员
for player in players[0:3]:
  print(player)

# 复制切片
my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
friend_foods.append('jiaozi')
friend_foods.insert(0, 'hotpot')
print(my_foods)
print(friend_foods)

# 4-10 切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print('The first three items in the list are:')
print(players[0:3])
print('Three items from the middle of the list are:')
print(players[1:4])
print('The last three items in the list are:')
print(players[-3:])

0ad3b750c0a30876b3295052ee7e53d698fcb0e5
<mask token>

<mask token>
print(players[0:3])
print(players[1:4])
print(players[:4])
print(players[2:])
print(players[-3:])
for player in players[0:3]:
    print(player)
<mask token>
friend_foods.append('jiaozi')
friend_foods.insert(0, 'hotpot')
print(my_foods)
print(friend_foods)
<mask token>
print('The first three items in the list are:')
print(players[0:3])
print('Three items from the middle of the list are:')
print(players[1:4])
print('The last three items in the list are:')
print(players[-3:])

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])
print(players[1:4])
print(players[:4])
print(players[2:])
print(players[-3:])
for player in players[0:3]:
    print(player)
my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
friend_foods.append('jiaozi')
friend_foods.insert(0, 'hotpot')
print(my_foods)
print(friend_foods)
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print('The first three items in the list are:')
print(players[0:3])
print('Three items from the middle of the list are:')
print(players[1:4])
print('The last three items in the list are:')
print(players[-3:])

# 使用列表中的一部分——切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])
print(players[1:4])
print(players[:4])
print(players[2:])
print(players[-3:])

# 遍历前三名运动员
for player in players[0:3]:
  print(player)

# 复制切片
my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
friend_foods.append('jiaozi')
friend_foods.insert(0, 'hotpot')
print(my_foods)
print(friend_foods)

# 4-10 切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print('The first three items in the list are:')
print(players[0:3])
print('Three items from the middle of the list are:')
print(players[1:4])
print('The last three items in the list are:')
print(players[-3:])
