Python的编号列表

2024-05-13 20:18:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要用python中的list元素制作一个编号列表。 示例列表:

destinations = ['Los Angeles ', 'Rhodos ', 'Dubai ', 'Manila ', 'Mallorca ', 'New York ']

我需要将元素打印为编号列表:

1. Los Angeles 
2. Rhodos 
3. Dubai 
4. Manila 
5. Mallorca 
6. New York

如果我这样做了:

print ('\n'.join(destinations)) 

它在单独的行上打印出元素,但我不能添加数字。


Tags: 元素示例列表new编号listprintyork