mercredi 20 mars 2019

Create a list of random integers and then put all numbers that are the same right beside eachother

def run():
    lst=[]
    for i in range(0,20):
        ran = random.randint(1,10)
        lst.append(ran)
return lst

So far I have created a list of random integers from 1 to 9 with 20 values, however how can I incorporate a swapping method so that values that are the same but not next to eachother will be next to eachother?

Thanks




Aucun commentaire:

Enregistrer un commentaire