Add files via upload

This commit is contained in:
Daniel
2023-01-24 21:09:24 +02:00
committed by GitHub
commit aad45e8967
2 changed files with 58128 additions and 0 deletions

58111
english.txt Normal file

File diff suppressed because it is too large Load Diff

17
hangman.py Normal file
View File

@@ -0,0 +1,17 @@
length_word = int(input("Enter the length of the word:"))
words, word = [], ''.join(['_' for x in range(length_word)])
with open('english.txt', 'r', encoding="utf-8") as wordlist:
for x in wordlist:
words.append(x)
possibleWords = [x[:len(x) - 1] for x in words if len(x) == length_word + 1]
while input("Continue? y/n") != "n":
t = int(input("How many of the same letter do you wanna input?"))
for j in range(t):
g, d = input("Right or wrong? r/w"), input("Letter?")
if g == 'r':
p = int(input("Position?"))
word = word[:p - 1] + d.upper() + word[p:]
possibleWords = [x for x in possibleWords if x[p - 1] == d.upper() and x.count(d.upper()) == t]
else:
possibleWords = [x for x in possibleWords if d.upper() not in x]
print(possibleWords)