[Python] How to remove list elements in a for loop in Python? [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 17, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list

    a = ["a", "b", "c", "d", "e"]


    I want to remove elements in this list in a for loop like below:

    for item in a:
    print(item)
    a.remove(item)


    But it doesn't work. What can I do?

    Continue reading...

Compartilhe esta Página