小编sha*_*eek的帖子

在Python中一次迭代2个列表

我想将特定金额分享/分配给两个Python列表的成员.list1的成员每个都有两个共享,而list2的成员每个都有一个共享,然后打印出结果,并分配名称和值.以下是我的示例代码:

reminder = float(85000)

list1 = ['Designer', 'Coder', 'Supervisor']
list2 = ['Artist', 'Attendant', 'Usher]

for i,j in list1 and list2:
    print(i, (reminder/9)*2)
    print(j, (reminder/9)*1)
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,我得到了一个例外:

Traceback (most recent call last):
  File "C:\Python33\reminder.py", line 6, in <module>
    for i,j in list1 and list2:
ValueError: too many values to unpack (expected 2)
Run Code Online (Sandbox Code Playgroud)

我搜索过相同主题的先前帖子,但无法找到解决方案.

我该怎么办呢?

python iteration list

1
推荐指数
1
解决办法
2972
查看次数

标签 统计

iteration ×1

list ×1

python ×1