Iterating over two lists one after another

前端 未结 3 1351
长情又很酷
长情又很酷 2020-12-06 10:01

I have two lists list1 and list2 of numbers, and I want to iterate over them with the same instructions. Like this:

for item in lis         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 10:23

    How about this:

    for item in list1 + list2:
        print(item.amount)
        print(item.total_amount)
    

    Only 3 lines

提交回复
热议问题