简体   繁体   English

列表中的连续数字

[英]Consecutive numbers on list

I have a list and want to show this list with consecutive numbers like;我有一个列表,想用连续的数字显示这个列表; 1.Test 2.Hello 3. Bye 1.测试 2.你好 3.再见

I use enumerate(list,1) function and get variables like 1Test, 2Hello 3Bye我使用enumerate(list,1) function 并获取 1Test、2Hello 3Bye 等变量

are there any function or way in python to get dotted (consecutive) numbers for a better-ordered list?是否有任何 function 或 python 的方式来获得点状(连续)数字以获得更好的排序列表?

Try this,尝试这个,

items = ['test','hello','bye']
for x, y in enumerate(items,1):
    print(f'{x}.{y}')

Your output will be您的 output 将

1.test
2.hello
3.bye

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM