编写一个python程序 打印消息“The first three items in the list are”,再使用切片来打印列表的前三个元素,中间三个元素,末尾三个元素。
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print("The first three items in the list are:") print(lst[:3])
print("The middle three items in the list are:") print(lst[3:6])
print("The last three items in the list are:") print(lst[-3:])
原文地址: https://www.cveoy.top/t/topic/tvR 著作权归作者所有。请勿转载和采集!