📜  如何在python代码示例中打印备用数字

📅  最后修改于: 2022-03-11 14:46:13.335000             🧑  作者: Mango

代码示例1
list = [1,2,3,4,5]
alternate_list = list[::2] 
#as we are looking for even indices only, and 2 is the smallest even number
#so, using list[::2] slices every second item of the list 
for item in alternate_list:
  print(item)
 
#Hope this helps:)