-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
102 lines (80 loc) · 3.2 KB
/
main.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from checking import check
from wordfile import get_word
# ----------------------------------------------------------------------------------------------------------------------
def main1():
word = get_word()
guesses = []
guessed = False
print()
print("The word contains", len(word), "letters.")
print("_ " * len(word))
while not guessed:
print()
text = "Please enter one letter or a word of " + str(len(word)) + " letters : "
guess = input(text).upper()
if guess.isalpha() == True:
if guess in guesses:
print('''
You have already guessed "''' + guess + '".')
elif len(guess) == len(word):
guesses.append(guess)
if guess == word:
guessed = True
else:
print('''
Sorry,that is incorrect word.''')
elif len(guess) == 1:
guesses.append(guess)
result = check(word, guesses, guess)
if result == word:
guessed = True
else:
print(result)
else:
print("Invalid Entry.")
print()
print('''You had guessed following letters : ''', guesses[0:len(guesses)])
else:
print("Please enter only alphabets, not numbers or any other special characters !!!")
print('''
Yes,the word is''', word + "! You got it in", len(guesses), "tries.")
# ----------------------------------------------------------------------------------------------------------------------
def main2():
word = input('Enter a word : ').upper()
guesses = []
guessed = False
print()
print("The word contains", len(word), "letters.")
print("_ " * len(word))
while not guessed:
print()
text = "Please enter one letter or a word of " + str(len(word)) + " letters : "
guess = input(text)
guess = guess.upper()
if guess.isalpha() == True:
if guess in guesses:
print('''
You have already guessed "''' + guess + '"')
elif len(guess) == len(word):
guesses.append(guess)
if guess == word:
guessed = True
else:
print('''
Sorry,that is incorrect''')
elif len(guess) == 1:
guesses.append(guess)
result = check(word, guesses, guess)
if result == word:
guessed = True
else:
print(result)
else:
print("Invalid Entry.")
print()
print('''You had guessed following letters : ''', guesses[0:len(guesses)])
else:
print("Please enter only alphabets, not numbers or any other special characters !!!")
print('''
Yes,the word is''', word + "! You got it in", len(guesses), "tries.")
# ----------------------------------------------------------------------------------------------------------------------