Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import random
- anzVersuche = 10
- versuch = 0
- gefunden = 0
- def getWords():
- wortliste = []
- file = open('wortliste.txt')
- for word in file:
- wortliste.append(word)
- # get random word
- gesWort = wortliste[random.randrange(0, len(wortliste), 1)]
- return gesWort
- gesWort = getWords()
- gezWort = ['*'] * (len(gesWort) - 1)
- print(gezWort)
- while versuch < anzVersuche:
- eingabe = input("Geben sie ihren Buchstaben ein: ")
- index = 0
- for buchstabe in gesWort:
- if (eingabe == buchstabe):
- gezWort[index] = eingabe
- gefunden += 1
- index += 1
- if (gefunden == len(gesWort) - 1):
- print(gezWort)
- print("GEWONNEN, das gesuchte Wort war", gesWort)
- break
- versuch += 1
- os.system('cls')
- print('Noch ', anzVersuche - versuch, " Versuche übrig")
- print(gezWort)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement