PDA

View Full Version : python repeat lists



dom_daly
January 16th, 2016, 09:13 PM
i have a code like this
list1 = [1,2,3,4,5]
list2 = [5,6,7]

when i add the two lists together it makes
[6,8,10,4,5]

how do make it so 5,6,7 repeats so it gets like this
[1,2,3,4,5]
[5,6,7,5,6]

so it repeats when the other is longer to make the answer
[6,8,10,9,11]
thanks!:D

ian-weisser
January 17th, 2016, 02:14 AM
Is this homework?

Vaphell
January 18th, 2016, 03:20 PM
have you tried multiplying the shorter list by a number and then trimming it to specific length?