-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions.txt
52 lines (36 loc) · 1.65 KB
/
extensions.txt
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
Extensions:
_______
1. At the moment your program is case sensitive,
so if the user guesses an uppercase 'A' it's not
going to count as a correct 'a' guess.
Fix it so 'A' and 'a' count as the same guess!
(hint: you may need the string method "string".lower():
https://docs.python.org/2/library/stdtypes.html#str.lower)
_______
2. If the user tries to guess a letter they've guessed before,
print something out telling them this.
_______
3. We're feeling nice today, so also modify the program so that
the user doesn't lose one of their guesses when they guess
something they've guessed before.
(hint: you made need to use the 'continue' keyword.
'continue' is similar to 'break'. It stops executing the current
loop iteration and continues from the next loop iteration.
See more here:
https://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops)
_______
4. If the user doesn't choose a letter but just presses enter,
or if they type more than one letter before hitting enter,
we still enter the loop, do all our checks and print stuff out.
It would be better if we instead printed out a message until the
user successfully enters a letter.
"Guess must be a single letter! Try again.\n"
(hint #1: you may also need to use the len() method:
https://docs.python.org/2/library/functions.html#len)
(hint #2: you may need another loop to achieve this inside your while loop.)
_______
5. Extend step 3 to also ensure the player can only guess alphabetic letters
and not numbers or special characters (eg '.', '$', '%' etc)
(hint: have a look at the isalpha() method:
https://docs.python.org/2/library/stdtypes.html#str.isalpha)
_______