-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathword_scrambler.py
More file actions
42 lines (29 loc) · 1.06 KB
/
word_scrambler.py
File metadata and controls
42 lines (29 loc) · 1.06 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
import random
while True:
words = ["apple", "banana", "computer", "python", "school", "car", "bike"]
word = random.choice(words)
scrambled = list(word)
random.shuffle(scrambled)
scrambled_word = "".join(scrambled)
if scrambled_word == word:
print("fck something went wrong")
scrambled = list(word)
random.shuffle(scrambled)
scrambled_word = "".join(scrambled)
tries = 1
max_tries = 3
while True:
guess = input(f"What is the original word? {scrambled_word} ")
if guess == word:
print("🎉 Correct! Well done!")
break
else:
tries += 1
if tries < max_tries:
print(f"❌ Wrong! You have ({tries}/{max_tries}) tries left!")
else:
print(f"💀 Game over! the correct word was {word}, next time better.")
start_again = input("\nWant again? (Yes/No) ").lower()
if start_again == "No":
print("Thanks for playing")
break