[Python] Python: Replace duplicate values in a list with the same values

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list and would like to convert all duplicates values to 3 without changing the order and without importing any packages

    X = [1, 2, 2, 5, 4, 8, 6]


    Desired output:

    X = [1, 3, 3, 5, 4, 8, 6]

    Continue reading...

Compartilhe esta Página