You add to the same line every time, but don't print between them. Instead, add another loop for:
list1 = ['x', 'y', 'z']
list2 = [1, 2, 3]
for i in range(len(list1)):
for x in list1[i] * list2[i]:
print(x)
This runs as:
>>> list1 = ['x', 'y', 'z']
>>> list2 = [1, 2, 3]
>>> for i in range(len(list1)):
... for x in list1[i] * list2[i]:
... print(x)
...
x
y
y
z
z
z
>>>
Instead of for i in range(0, len(list1)):making a different proposal for i in range(len(list1)). Python automatically accepts this as range(0, len(list1)):
>>> range(0, len(list1))
[0, 1, 2]
>>> range(len(list1))
[0, 1, 2]
>>>
However, if you want to add a leap for range(), you need toinclude 0:
>>> range(len(list1), 2)
[]
>>> range(0, len(list1), 2)
[0, 2]
>>>
, , , for, :
list1 = ['xx', 'yy', 'zz']
list2 = [1, 2, 3]
list1 = [list1[i]*list2[i] for i in range(len(list1))]
for k in ''.join(list1):
print k
:
>>> list1 = ['xx', 'yy', 'zz']
>>> list2 = [1, 2, 3]
>>> list1 = [list1[i]*list2[i] for i in range(len(list1))]
>>> for k in ''.join(list1):
... print k
...
x
x
y
y
y
y
z
z
z
z
z
z
>>> list1
['xx', 'yyyy', 'zzzzzz']
>>>