lundi 20 juillet 2020

I want to rewrite the below code using list comprehension. So basically i want to remove repeating elements from a list [duplicate]

i want to remove repeating elements from scores and store them in ranks.

    scores = [1,2,3,3,4,5,5,5]
    ranks = []
    for x in scores:
        if x not in ranks:
            ranks.append(x)

Aucun commentaire:

Enregistrer un commentaire