Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions hangman/hangman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from hangmanwords import words
import random

stages = ['''
+---+
| |
O |
/|\ |
/ \ |
|
=========
''', '''
+---+
| |
O |
/|\ |
/ |
|
=========
''', '''
+---+
| |
O |
/|\ |
|
|
=========
''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O |
| |
|
|
=========
''', '''
+---+
| |
O |
|
|
|
=========
''', '''
+---+
| |
|
|
|
|
=========
''']

def checkguess(word):
life = 6
empty = ['_'] * len(word)
word = word.upper()
end = False
while not end:
guess = input("Guess the letter :").upper()
for i in range(len(word)):
if (word[i] == guess):
empty[i] = word[i]
if guess not in word:
life -= 1
print(stages[life])
print(f"try again {life} life left ")
print(empty)
if '_' not in empty:
end = True
print("you win")
break
elif life == 0:
end = True


comp = random.choice(words)
checkguess(comp)
print(f"The word is {comp}")
74 changes: 74 additions & 0 deletions hangman/hangmanwords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
words = ['abandon', 'ability', 'able', 'about', 'above', 'accept', 'according', 'account', 'across', 'action', 'activity',
'actually', 'address', 'administration', 'admit', 'adult', 'affect', 'after', 'again', 'against', 'agency', 'agent',
'agree', 'agreement', 'ahead', 'allow', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'among',
'amount', 'analysis', 'animal', 'another', 'answer', 'anyone', 'anything', 'appear', 'apply', 'approach', 'area', 'argue',
'around', 'arrive', 'article', 'artist', 'assume', 'attack', 'attention', 'attorney', 'audience', 'author', 'authority',
'available', 'avoid', 'away', 'baby', 'back', 'ball', 'bank', 'base', 'beat', 'beautiful', 'because', 'become', 'before',
'begin', 'behavior', 'behind', 'believe', 'benefit', 'best', 'better', 'between', 'beyond', 'bill', 'billion', 'black',
'blood', 'blue', 'board', 'body', 'book', 'born', 'both', 'break', 'bring', 'brother', 'budget', 'build', 'building',
'business', 'bytecode', 'call', 'camera', 'campaign', 'cancer', 'candidate', 'capital', 'card', 'care', 'career', 'carry',
'case', 'catch', 'cause', 'cell', 'center', 'central', 'century', 'certain', 'certainly', 'chair', 'challenge', 'chance',
'change', 'character', 'charge', 'check', 'child', 'choice', 'choose', 'church', 'citizen', 'city', 'civil', 'claim',
'class', 'clear', 'clearly', 'close', 'coach', 'cold', 'collection', 'college', 'color', 'come', 'commercial', 'common',
'community', 'company', 'compare', 'computer', 'concern', 'condition', 'conference', 'consider', 'consumer', 'contain',
'continue', 'control', 'cost', 'could', 'country', 'couple', 'course', 'court', 'cover', 'create', 'crime', 'cultural',
'culture', 'current', 'customer', 'dark', 'data', 'daughter', 'dead', 'deal', 'death', 'debate', 'decade', 'decide',
'decision', 'deep', 'defense', 'degree', 'describe', 'design', 'despite', 'detail', 'determine', 'develop', 'development',
'dictionary', 'difference', 'different', 'difficult', 'dinner', 'direction', 'director', 'discover', 'discuss',
'discussion', 'disease', 'doctor', 'door', 'down', 'draw', 'dream', 'drive', 'drop', 'during', 'each', 'early', 'east',
'easy', 'economic', 'economy', 'edge', 'education', 'effect', 'effort', 'eight', 'either', 'election', 'else', 'employee',
'energy', 'enjoy', 'enough', 'enter', 'entire', 'environment', 'environmental', 'especially', 'establish', 'even',
'evening', 'event', 'ever', 'every', 'everybody', 'everyone', 'everything', 'evidence', 'exactly', 'example', 'executive',
'exist', 'expect', 'experience', 'expert', 'explain', 'face', 'fact', 'factor', 'fall', 'false', 'family', 'fast',
'father', 'fear', 'federal', 'feel', 'feeling', 'field', 'fight', 'figure', 'fill', 'film', 'final', 'finally',
'financial', 'find', 'fine', 'finger', 'finish', 'fire', 'firm', 'first', 'fish', 'five', 'floor', 'focus', 'follow',
'food', 'foot', 'force', 'foreign', 'forget', 'form', 'former', 'forward', 'four', 'free', 'friend', 'from', 'front',
'full', 'function', 'fund', 'future', 'game', 'garden', 'general', 'generation', 'girl', 'give', 'glass', 'goal', 'good',
'government', 'great', 'green', 'ground', 'group', 'grow', 'growth', 'guess', 'guido', 'hair', 'half', 'hand', 'hang',
'happen', 'happy', 'hard', 'have', 'head', 'health', 'hear', 'heart', 'heat', 'heavy', 'help', 'here', 'herself', 'high',
'himself', 'history', 'hold', 'home', 'hope', 'hospital', 'hotel', 'hour', 'house', 'however', 'huge', 'human', 'hundred',
'husband', 'idea', 'identify', 'image', 'imagine', 'impact', 'import', 'important', 'improve', 'include', 'including',
'increase', 'indeed', 'indicate', 'individual', 'industry', 'information', 'inside', 'instead', 'institution', 'interest',
'interesting', 'international', 'interpreter', 'interview', 'into', 'investment', 'involve', 'issue', 'item', 'itself',
'join', 'just', 'keep', 'kill', 'kind', 'kitchen', 'know', 'knowledge', 'land', 'lambda', 'language', 'large', 'last',
'late', 'later', 'laugh', 'lawyer', 'lead', 'leader', 'learn', 'least', 'leave', 'left', 'legal', 'less', 'letter',
'level', 'life', 'light', 'like', 'likely', 'line', 'list', 'listen', 'little', 'live', 'local', 'long', 'look', 'loop',
'lose', 'loss', 'love', 'machine', 'magazine', 'main', 'maintain', 'major', 'majority', 'make', 'manage', 'management',
'manager', 'many', 'market', 'marriage', 'material', 'matter', 'maybe', 'mean', 'measure', 'media', 'medical', 'meet',
'meeting', 'member', 'memory', 'mention', 'message', 'method', 'middle', 'might', 'military', 'million', 'mind', 'minute',
'miss', 'mission', 'model', 'modern', 'moment', 'money', 'month', 'more', 'morning', 'most', 'mother', 'mouth', 'move',
'movement', 'movie', 'much', 'music', 'must', 'myself', 'name', 'nation', 'national', 'natural', 'nature', 'near',
'nearly', 'necessary', 'need', 'network', 'never', 'news', 'newspaper', 'next', 'nice', 'nightnone', 'north', 'note',
'nothing', 'notice', 'number', 'object', 'occur', 'offer', 'office', 'officer', 'official', 'often', 'once', 'only',
'onto', 'open', 'operation', 'opportunity', 'option', 'order', 'organization', 'other', 'others', 'outside', 'over',
'owner', 'page', 'pain', 'painting', 'paper', 'parameters', 'parent', 'part', 'participant', 'particular', 'particularly',
'partner', 'party', 'pass', 'past', 'patient', 'pattern', 'peace', 'people', 'perform', 'performance', 'perhaps',
'period', 'person', 'personal', 'phone', 'physical', 'pick', 'picture', 'piece', 'place', 'plan', 'plant', 'play',
'player', 'point', 'police', 'policy', 'political', 'politics', 'poor', 'popular', 'population', 'position', 'positive',
'possible', 'power', 'practice', 'prepare', 'present', 'president', 'pressure', 'pretty', 'prevent', 'price', 'print',
'private', 'probably', 'problem', 'process', 'produce', 'product', 'production', 'professional', 'professor', 'program',
'project', 'property', 'protect', 'prove', 'provide', 'public', 'pull', 'purpose', 'push', 'pydis', 'pygame', 'python',
'quality', 'question', 'quickly', 'quite', 'race', 'radio', 'raise', 'range', 'rate', 'rather', 'reach', 'read', 'ready',
'real', 'reality', 'realize', 'really', 'reason', 'receive', 'recent', 'recently', 'recognize', 'record', 'reduce',
'reflect', 'region', 'relate', 'relationship', 'remain', 'remember', 'remove', 'report', 'represent', 'require',
'research', 'resource', 'respond', 'response', 'responsibility', 'rest', 'result', 'return', 'reveal', 'rich', 'right',
'rise', 'risk', 'road', 'rock', 'role', 'room', 'rule', 'safe', 'same', 'save', 'scene', 'school', 'science', 'scientist',
'score', 'season', 'seat', 'second', 'section', 'security', 'seek', 'seem', 'sell', 'send', 'senior', 'sense', 'series',
'serious', 'serve', 'service', 'seven', 'several', 'shake', 'share', 'shoot', 'short', 'shot', 'should', 'shoulder',
'show', 'side', 'sign', 'significant', 'similar', 'simple', 'simply', 'since', 'sing', 'single', 'sister', 'site',
'situation', 'size', 'skill', 'skin', 'small', 'smile', 'social', 'society', 'soldier', 'some', 'somebody', 'someone',
'something', 'sometimes', 'song', 'soon', 'sort', 'sound', 'source', 'south', 'southern', 'space', 'speak', 'special',
'specific', 'speech', 'spend', 'sport', 'spring', 'staff', 'stage', 'stand', 'standard', 'star', 'start', 'state',
'statement', 'station', 'stay', 'step', 'still', 'stock', 'stop', 'store', 'story', 'strategy', 'street', 'strong',
'structure', 'student', 'study', 'stuff', 'style', 'subject', 'success', 'successful', 'such', 'suddenly', 'suffer',
'suggest', 'summer', 'support', 'sure', 'surface', 'system', 'table', 'take', 'talk', 'task', 'teach', 'teacher',
'team', 'technology', 'television', 'tell', 'tend', 'term', 'test', 'than', 'thank', 'that', 'their', 'them',
'themselves', 'then', 'theory', 'there', 'these', 'they', 'thing', 'think', 'third', 'this', 'those', 'though', 'thought',
'thousand', 'threat', 'three', 'through', 'throughout', 'throw', 'thus', 'time', 'today', 'together', 'tonight', 'total',
'tough', 'toward', 'town', 'trade', 'traditional', 'training', 'travel', 'treat', 'treatment', 'tree', 'trial', 'trip',
'trouble', 'true', 'truth', 'turn', 'type', 'under', 'understand', 'unit', 'until', 'upon', 'usually', 'value',
'variable', 'various', 'very', 'victim', 'view', 'visit', 'voice', 'vote', 'wait', 'walk', 'wall', 'want', 'watch',
'water', 'wear', 'week', 'weight', 'well', 'west', 'western', 'what', 'whatever', 'when', 'where', 'whether', 'which',
'while', 'white', 'whole', 'whom', 'whose', 'wide', 'wife', 'will', 'wind', 'window', 'wish', 'with', 'within',
'without', 'woman', 'wonder', 'word', 'work', 'worker', 'world', 'worry', 'would', 'write', 'writer', 'wrong', 'yard',
'yield', 'yeah', 'year', 'young', 'your', 'yourself']