-1
list1=  ['a','b','c']
list2=  ['d','e','f']

我想做这样的循环

输出:

"hi I am" + list1[1] + "is also" + list2[1]   i.e. Hi I am a is also d
"hi I am" + list1[2] + "is also" + list2[2]   i.e. Hi I am b is also e ....
"hi I am" + list1[3] + "is also" + list2[3]

忽略示例:P*

4

2 回答 2

0

请阅读有关zip

for i, j in zip(list1, list2):
    print("hi I am " + i + " is also " + j)
#hi I am a is also d
#hi I am b is also e
#hi I am c is also f
于 2020-05-15T00:53:26.283 回答
0
for i in range(len(list1)):
    print("hi I am " + list1[i] + " is also " + list2[i])
于 2020-05-15T00:29:13.590 回答