HILFE-Lottoprogramm schreiben
Verfasst: Sonntag 9. Dezember 2018, 16:55
Hallo, ich brauche ganz dringend eure hilfe ! Ich muss bis morgen ein Lottoprogramm schreiben, welches keine Zahlen doppelt wählt, Lottotipps abfragt und am Ende ausgebt wie viele richtige Tipps man hat. Das habe ich bereits geschafft, nun fehlt mir nur noch die Aufgabe, dass nach der Anzahl der Lottodurchgänge gefragt werden soll und am Ende alle richtigen der ganzen Durchläufe aufgelistet werden sollen. Hoffentlich versteht ihr mein Programm soweit. Über einen Lösungsvorschlag würde ich mich sehr freuen
lottozahlen = {}
lottotipp = {}
import random
print("Ziehung der Lotozahlen:")
for i in range(0,6):
doppelt = True
while doppelt:
neu=int(input("Eine Lottozahl eingeben:"))
if lottotipp.count(neu) == 0:
lottotipp.append(neu)
doppelt = False
else: print(neu,"doppelt getippt")
lottotipp.sort()
print()
print("Dein Lottotipp:")
print(lottotipp)
print()
anzahl=int(input("WIe viele Ziehungen sollen gemacht werden"))
for i in range (anzahl):
for i in range(0,6):
while (neu in lottozahlen) or (neu==0):
neu=random.randint(1,49)
lottozahlen.append(neu)
lottozahlen.sort()
print("Ziehung der Lottozahlen:")
print (lottozahlen)
print()
richtige = {0,0,0,0,0,0,0}
anzahl_richtige = 0
for i in range(0,6):
if lottotipp {i} in lottozahlen:
anzahl_richtige = anzahl_richtige+1
richtige{anzahl_richtige}=richtige{anzahl_richtige}+1
print("Richtige")
print(" 1 2 3 4 5 6 ")
print(richtige)
lottozahlen = {}
lottotipp = {}
import random
print("Ziehung der Lotozahlen:")
for i in range(0,6):
doppelt = True
while doppelt:
neu=int(input("Eine Lottozahl eingeben:"))
if lottotipp.count(neu) == 0:
lottotipp.append(neu)
doppelt = False
else: print(neu,"doppelt getippt")
lottotipp.sort()
print()
print("Dein Lottotipp:")
print(lottotipp)
print()
anzahl=int(input("WIe viele Ziehungen sollen gemacht werden"))
for i in range (anzahl):
for i in range(0,6):
while (neu in lottozahlen) or (neu==0):
neu=random.randint(1,49)
lottozahlen.append(neu)
lottozahlen.sort()
print("Ziehung der Lottozahlen:")
print (lottozahlen)
print()
richtige = {0,0,0,0,0,0,0}
anzahl_richtige = 0
for i in range(0,6):
if lottotipp {i} in lottozahlen:
anzahl_richtige = anzahl_richtige+1
richtige{anzahl_richtige}=richtige{anzahl_richtige}+1
print("Richtige")
print(" 1 2 3 4 5 6 ")
print(richtige)