[Python] Repeating each element in a list

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have two lists:

    x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    y= [5, 2, 3, 2, 3, 3, 3, 3, 5, 3]


    I want to create a new list that contains of multiplies x's first element with the amount of y's first element. That is, I'm looking to produce:

    z = [0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, ...]


    How can I create this list?

    Continue reading...

Compartilhe esta Página