以下程序运行结果是 ( )。

list_a = [5, 2, 10, 6, 8, 13, 7]
list_a.reverse()
print(list_a[2])

结果: 10

解释:

  1. list_a.reverse() 将列表 list_a 反转,使其变成 [7, 13, 8, 6, 10, 2, 5]
  2. print(list_a[2]) 访问反转后的列表的第三个元素 (索引为 2),因此输出为 10。
Python 列表反转后元素访问:示例详解

原文地址: https://www.cveoy.top/t/topic/ntAb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录