-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathword_guesser.py
More file actions
30 lines (24 loc) · 841 Bytes
/
word_guesser.py
File metadata and controls
30 lines (24 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import random
while True:
wordlist = ["apple", "banana", "computer", "python", "school", "car", "bike"]
random_word = random.choice(wordlist)
first_letter = random_word[0]
tries = 0
max_tries = 3
while True:
guess = input("Raad de eerste letter van het woord. ").lower
if guess == first_letter:
print("Congrats, you did it!")
break
else:
tries += 1
if tries < max_tries:
print(f"You got ({tries}/{max_tries} tries left)")
print("Sad, try again!")
else:
print("Sad, you failed the game!")
break
start_again = input("\nWant again? (Yes/No) ").lower()
if start_again == "No":
print("Thanks for playing")
break