Files
inf-kswo/RandomOtherStuff/Wortraten spiel.py
Janis Hutz ede0ee318b Format
There really is no hope of making this code even half-way decent without
spending the time to rewrite them all properly. Don't want to do any of
that
2025-11-03 17:08:35 +01:00

221 lines
4.1 KiB
Python
Executable File

import os
global mistakes
mistakes = 0
global wortelements
wortelements = []
global done
done = []
def clear_screen():
os.system("cls")
def worteingabe():
global wort
wort = input("Suchen sie ein Wort, welches erraten werden soll, ein: ")
clear_screen()
print("Vielen Dank. Das Wort wurde gespeichert.")
print("Geben Sie das Gerät weiter.")
ausgabe(wort)
def ausgabe(wort):
global wortelements
print(
"""
Das Wort:
"""
)
print(len(wort) * "*")
global wholewordlist
wholewordlist = list(wort)
wortelements = list(len(wort) * "*")
def ersetzen(letter):
global wort
global wortelements
global wholewordlist
global done
while letter in wholewordlist:
pos = wholewordlist.index(letter)
wholewordlist.pop(pos)
wholewordlist.insert(pos, "*")
wortelements.pop(pos)
wortelements.insert(pos, letter)
def raten():
global wort
global wortelements
global wholewordlist
global go
go = 1
while go == 1:
buchstabe = input(
"Suchen sie einen Buchstaben aus, welcher sich im Wort befinden könnte: "
)
if buchstabe in wholewordlist:
print("Der Buchstabe kommt hier vor:")
ersetzen(buchstabe)
print(*wortelements)
done.append(buchstabe)
elif buchstabe in done:
print("Dieser Buchstabe wurde bereits eingetippt.")
addman()
elif buchstabe == wort:
wholewordlist = list(len(wort) * "*")
else:
print("Dieser Buchstabe ist nicht Teil des Wortes")
done.append(buchstabe)
addman()
print(*done)
counts = wholewordlist.count("*")
if len(wort) - counts <= 0:
go = 0
else:
print(
"""
DAS WORT WURDE GEFUNDEN
Das Wort:
"""
)
print(wort)
def addman():
global mistakes
mistakes += 1
if mistakes == 1:
print(
"""
__________
"""
)
elif mistakes == 2:
print(
"""
|
_____|_____
"""
)
elif mistakes == 3:
print(
"""
|
|
|
_____|_____
"""
)
elif mistakes == 4:
print(
"""
|
|
|
|
|\
_____|_\___
"""
)
elif mistakes == 5:
print(
"""
_____
|
|
|
|
|\
_____|_\___
"""
)
elif mistakes == 6:
print(
"""
_____
| |
| °
|
|
|\
_____|_\___
"""
)
elif mistakes == 6:
print(
"""
_____
| |
| °
| \
|
|\
_____|_\___
"""
)
elif mistakes == 7:
print(
"""
_____
| |
| °
| \/
|
|\
_____|_\___
"""
)
elif mistakes == 8:
print(
"""
_____
| |
| °
| \/
| /
|\
_____|_\___
"""
)
elif mistakes == 9:
print(
"""
_____
| |
| °
| \/
| /\
|\
_____|_\___
DEAD
"""
)
global go
go = 0
worteingabe()
raten()