我创建了以下列表:
Stores = ['Costco','Publix', 'Kroger', 'Target']
我被要求创建另一个列表(Store\u Rank),通过在前面添加整数来定义它们的排名。但是,整数应该是列表格式。你知道吗
我假设使用f插值?你知道吗
“商店排名”列表应输出以下内容:
1. Costco, 2. Publix, 3. Kroger, 4. Target
注:预期结果为
Store_Rank [0] = 1. Costco
Store_Rank[2] = 2. Publix
等等。。你知道吗
请帮帮我!你知道吗
使用
enumerate
的短代码使用代码:
如果您使用的是Python3.6+,则可以使用列表和f字符串,如下所示:
相关问题 更多 >
编程相关推荐