1 | import random
|
---|
2 |
|
---|
3 | def scramble(word):
|
---|
4 | scrambled = list(word)
|
---|
5 | for x in range(len(word)):
|
---|
6 | r = random.randint(0, len(word) - 1)
|
---|
7 | temp = scrambled[x]
|
---|
8 | scrambled[x] = scrambled[r]
|
---|
9 | scrambled[r] = temp
|
---|
10 | return scrambled
|
---|
11 |
|
---|
12 | words = ['apple', 'dude', 'croquet', 'granted']
|
---|
13 |
|
---|
14 | i = random.randint(0,len(words)-1)
|
---|
15 | word = words[i]
|
---|
16 | scrambled = scramble(word)
|
---|
17 |
|
---|
18 | print("Guess the Anagram")
|
---|
19 | print("".join(scrambled).upper())
|
---|
20 |
|
---|
21 | while True:
|
---|
22 | g = raw_input("Guess: ")
|
---|
23 | print(g)
|
---|
24 |
|
---|
25 | if g == word:
|
---|
26 | print('Well done, you win!')
|
---|
27 | break
|
---|
28 | else:
|
---|
29 | print('Wrong answer dumbass!')
|
---|