Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fc2aa8

Browse files
committed
一个for中遍历两列表
1 parent 4a5b502 commit 7fc2aa8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

how_for_two_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#coding:utf-8
22
#################
3+
# for循环两个列表的过程
34
list1 = ['1', '1']
45
list2 = ['A','B']
56

@@ -22,7 +23,7 @@
2223
# 这段代码是遍历两个列表之后赋值给新的两个列表
2324
for i in xq, yw:
2425
answer, question = i[:] # 这里可以加代码对元素操作之后再赋值给新的列表
25-
print answer, ",", question
26+
print answer, ",", question # 你可以把这句放在for循环外面在看下结果
2627

2728
print "---------"
2829
# 复杂版

0 commit comments

Comments
 (0)