python-function-zip

来源:互联网 发布:幻萌网络微博 编辑:程序博客网 时间:2024/05/29 15:10

zip will create pairs of elements when passed two lists, and will stop at the end of the shorter list.

zip can handle three or more lists as well!

code:

<span style="font-size:18px;">list_a = [3, 9, 17, 15, 19]list_b = [2, 4, 8, 10, 30, 40, 50, 60, 70, 80, 90]for a, b in zip(list_a, list_b):    print max(a,b)</span>


0 0
原创粉丝点击