如何用Python同时打印列表元素的索引和值?

2026-05-21 20:150阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计78个文字,预计阅读时间需要1分钟。

如何用Python同时打印列表元素的索引和值?

pythonIn [1]: list01=[1, 4, 5]In [10]: def funct01(ll): ...: for index, value in enumerate(ll): ...: print(index, value) ...: In [11]: funct01(list01)

01

14

如何用Python同时打印列表元素的索引和值?

25

In [1]: list01=[1,4,5]

In [10]: def funct01(ll):
....: for index,value in enumerate(ll):
....: print index,value
....:

In [11]: funct01(list01)
0 1
1 4
2 5


本文共计78个文字,预计阅读时间需要1分钟。

如何用Python同时打印列表元素的索引和值?

pythonIn [1]: list01=[1, 4, 5]In [10]: def funct01(ll): ...: for index, value in enumerate(ll): ...: print(index, value) ...: In [11]: funct01(list01)

01

14

如何用Python同时打印列表元素的索引和值?

25

In [1]: list01=[1,4,5]

In [10]: def funct01(ll):
....: for index,value in enumerate(ll):
....: print index,value
....:

In [11]: funct01(list01)
0 1
1 4
2 5