diff --git a/yatz b/yatz new file mode 100644 index 0000000000000000000000000000000000000000..c8c958cbd07a3fde805e32c47728dafb1cc21d2d --- /dev/null +++ b/yatz @@ -0,0 +1,54 @@ +import random + + +def nopanheitto(noppa): + print("Hyvä heitto!") + print('Heitit', end= '') + for n in noppa: + print(str(n)+' ', end='') + +tulos=0 +tuloslista=[] + +while not peli_päättyy: + noppa=[] + for n in range(5): + noppa.append(random.randint(1,6)) + + nopanheitto(noppa) + + uusiheitto=input("Minkä nopan haluat heittää uudestaan?") + uusiheitto=uusiheitto.split() + for index, ch in enumerate(uusiheitto): + uusiheitto[index]= int(ch)-1 + + for index in uusiheitto: + noppa[index]=random.randint(1,6) + + + numero_käy=False + while not numero_käy: + lopputulos=int(input("Mitä haluat tulokseksi?")) + + if lopputulos not in tuloslista: + numero_käy=True + + else: + print("Olet jo heittänyt nämä numerot.") + print("Heitit numerot", end='') + for numero in tuloslista: + print(str(numero)+ '', end='') + print() + + + + tuloslista.append(lopputulos) + + for d in noppa: + if d==tulos: + tulos+=d + + print("Tuloksesi on "+ str(tulos)) + + if len(tuloslista)==6: + peli_päättyy=True \ No newline at end of file