Anzahl der doppelten Zahlen ausgeben
Verfasst: Freitag 13. Januar 2017, 10:35
Hallo, ich bin absoluter Neuling und benötige Hilfe.
Ich hab das Programm schon fast fertig, mir fehlt nur noch die Anzahl.
Bsp.
Ausgabe: 3 3 4 5
Dann soll als Antwort kommen: Die 3 kommt 2 mal vor.
Wie kommt man auf die 2?
Ich bin dankbar für eure Hilfe.
PS: Mir fehlt der Code unten bei #Anzahl berechnen
Mein Code:
Ich hab das Programm schon fast fertig, mir fehlt nur noch die Anzahl.
Bsp.
Ausgabe: 3 3 4 5
Dann soll als Antwort kommen: Die 3 kommt 2 mal vor.
Wie kommt man auf die 2?
Ich bin dankbar für eure Hilfe.
PS: Mir fehlt der Code unten bei #Anzahl berechnen
Mein Code:
Code: Alles auswählen
from random import randint
import numpy as np
eingabe1 = int(input("Bitte die Häufigkeit eingeben: "))
eingabe2 = int(input("Soll Ihr Würfel 4, 6, oder 12 Seitig sein(Eingabe: 4, 6, 12)? "))
i = 0
while i < eingabe1:
if eingabe2 == 4:
w1 = randint(1, 4)
w2 = randint(1, 4)
elif eingabe2 == 6:
w1 = randint(1, 6)
w2 = randint(1, 6)
elif eingabe2 == 12:
w1 = randint(1, 12)
w2 = randint(1, 12)
erg = w1 + w2
i+=1
print(erg)
summe = np.array(erg)
#Anzahl berechnen
print(summe, 'wurde (mit) am häufigsten gewürfelt mit ',anzahl, ' mal.')