From 5166774d724f0986d0d6fedff4657a1d36d93e47 Mon Sep 17 00:00:00 2001 From: Ada Ojuva <ada.s.ojuva@utu.fi> Date: Fri, 16 Dec 2022 08:54:04 +0000 Subject: [PATCH] Upload New File --- yatz | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 yatz diff --git a/yatz b/yatz new file mode 100644 index 0000000..c8c958c --- /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 -- GitLab