This commit is contained in:
alstergym
2026-09-04 08:59:43 +02:00
parent 890c43674d
commit 7f7ddbe04a
5 changed files with 108 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
import random
def auswertung():
while True:
try:
zahl = int(input("Dein Tipp: "))
return zahl
except ValueError:
print("Bitte gib eine ganze Zahl ein.")
geheimzahl = random.randint(1, 100)
versuche = 0
print("Ich denke mir eine Zahl zwischen 1 und 100 aus.")
print("Versuche, sie zu erraten!")
while True:
tipp = auswertung()
versuche += 1
if tipp < geheimzahl:
print("Zu klein!")
elif tipp > geheimzahl:
print("Zu groß!")
else:
print("Richtig!")
print("Du hast", versuche, "Versuche gebraucht.")
break