Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
There is a built-in function for thiszip
aa = [1,2,3]
bb=['a','b','c']
for a, b in zip(aa, bb):
print(str(a)+"swap"+b)
Depending on how you need to sort through, in what order. If you need to show the i-th element from
for each i -th element from , then they will have a common index, and you need to focus on it:a
b
a = [1,2,3]
b = ['a','b','c']
i = 0
while i < len(a):
print(str(a[i])+" swap "+b[i])
i += 1
a = [1,2,3]
b = ['a','b','c']
for i in a:
for j in b:
print(str(i)+" swap "+j)
>>> a = [1,2,3]
>>> b=['a','b','c']
>>> for i in zip(a,b):
... print(str(i[0])+"swap"+i[1])
...
1swapa
2swapb
3swapc
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question