I have 2 lists :
x = ['a','b','c']
y = ['d','e','f']
I need a single list of lists :
z = [['a','d'],['b','e'],['c','f']]
What I tried :
# Concatenate x and y with a space
w = []
for i in range(len(x)):
w.append(x[i]+" "+y[i])
# Split each concatenated element into a sublist
z = []
for i in range(len(w)):
z.append(w[i].split())
Is there a way to do this directly without using 2 for loops ? (I am very new to Python)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…