mardi 15 octobre 2019

Is this code efficient? Is it a good code?

I'm trying to learn coding and i want to know if you think this is a good code and how can i improve it? Excuse me if this is the wrong place to ask this question

from random import randint
from copy import deepcopy


lista1 = ["hearts","spades","clubs","diamonds"]

lista2 = [2,3,4,5,6,7,8,9,10,"jack","Queen","king","ace"]

lista3 = []


for i in lista1:
    for j in lista2:
        lista3.append([i,j])

def mischia(lista3):
    i = 0
    lista4 = []
    while i < len(lista3):
        x = randint(0,len(lista3)-1)
        if lista3[x] not in lista4:
            lista4.append(lista3[x])
            i+= 1
        else:
            continue
    return lista4



lista3 = mischia(lista3)


for coppie in lista3:
    print(coppie[1], "of", coppie[0])



Aucun commentaire:

Enregistrer un commentaire