File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ def game(guess, number):
4
4
A simple comparition function for the guess game
5
5
'''
6
6
if guess < number :
7
- return - 1 # guessed lower
7
+ return - 1 # guessed lower
8
8
elif guess > number :
9
- return 1 # guessed higher
9
+ return 1 # guessed higher
10
10
else :
11
- return 0 # guessed correctly
11
+ return 0 # guessed correctly
Original file line number Diff line number Diff line change 1
1
from random import randint
2
2
from guess_game import game
3
3
4
+
4
5
def main ():
5
6
guess = None
6
7
guessed_times = 0
7
- number = randint (0 ,10 )
8
+ number = randint (0 , 10 )
8
9
not_finished = True
9
10
while not_finished :
10
- guess = int (input ('Guess the number between 0 and 10: ' ))
11
+ guess = int (input ('Guess the number between 0 and 10: ' ))
11
12
returned = game (guess , number )
12
13
if returned > 0 :
13
14
print ('Guessed higher' )
Original file line number Diff line number Diff line change @@ -12,20 +12,22 @@ def reverse(string):
12
12
''' Reverses a string'''
13
13
return string [::- 1 ]
14
14
15
+
15
16
def palindrome_test (word ):
16
17
''' Returns true if a word is palindrome '''
17
18
if remove_special_char (word ) == reverse (remove_special_char (word )):
18
19
return True
19
20
else :
20
21
return False
21
22
23
+
22
24
def main ():
23
25
test = palindrome_test (input ("Type a word to test if it is palindrome: " ))
24
26
if test :
25
27
print (f"The word is palindrome" )
26
28
else :
27
29
print (f"The word isn't palindrome" )
28
30
31
+
29
32
if __name__ == '__main__' :
30
33
main ()
31
-
You can’t perform that action at this time.
0 commit comments