Last active
December 28, 2019 04:11
-
-
Save Bundi-py/037fcfb7a57ddd6e76c5dea29ca2250b to your computer and use it in GitHub Desktop.
Napravi špil karata, promešaj ga, podeli po 6 karata četvorici igrača i isprintaj ko ima koje karte i šta je ostalo u špilu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
boja = ['p', 'h', 'k', 't'] | |
vrednost = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] | |
def napraviShpil(): | |
karte = [] | |
for i in boja: | |
for j in vrednost: | |
karte.append(j + i) | |
return karte | |
print(karte) | |
def meshanje(karte): | |
for i in range(0, 52): | |
promena = random.randrange(i, 52) | |
priv = karte[i] | |
karte[i] = karte[promena] | |
karte[promena] = priv | |
def glavna(): | |
karte = napraviShpil() | |
print('Početni špil: ') | |
print(karte) | |
print() | |
meshanje(karte) | |
print('Promešane karte: ') | |
print(karte) | |
c = random.choice(karte [10:40]) # precepi karte | |
cepaj = karte.index(c) | |
noviShpil = karte[cepaj:] + karte[:cepaj] | |
print() | |
print('**********') | |
print('Igrač 1:', noviShpil[0:6]) #podeli karte | |
print('Igrač 2:', noviShpil[6:12]) | |
print('Igrač 3:', noviShpil[12:18]) | |
print('Igrač 4:', noviShpil[18:24]) | |
del noviShpil[0:24] | |
print() | |
print('**********') | |
print('Preostale karte:', len(noviShpil)) | |
print(noviShpil) | |
glavna() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment