forked from 4dsolutions/Python5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkw_quiz.py
More file actions
38 lines (30 loc) · 866 Bytes
/
kw_quiz.py
File metadata and controls
38 lines (30 loc) · 866 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 10 21:15:06 2016
@author: kurner
Keywords Quiz
Can you think of them all?
An idea I picked up at a Python User Group...
"""
import keyword
all_kw = keyword.kwlist[:] # make a copy
found = [ ]
while len(all_kw) > 0:
print("{} keywords left to guess".format(len(all_kw)))
guess = input("What is your guess? (q to quit): ")
if guess == 'q':
print("You gave up!")
print("Unguessed: ", all_kw)
print("Guessed: ", found)
break
if guess in all_kw:
print("Yes, that's one of them")
all_kw.remove(guess)
found.append(guess)
elif guess in found:
print("You got that one already")
print("Found:", found)
else:
print("{} is not a keyword in Python.".format(guess))
else:
print("Congratulations; you got them all!")