-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame2.py
More file actions
25 lines (21 loc) · 769 Bytes
/
Game2.py
File metadata and controls
25 lines (21 loc) · 769 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
import random
word_bank = ['rizz', 'ohio', 'sigma', 'tiktok', 'skibidi']
word = random.choice(word_bank)
guessedWord = ['_'] * len(word)
attempts = 10
while attempts > 0:
print('\nCurrent word: ' + ' '.join(guessedWord))
guess = input('Guess a letter: ').lower()
if guess in word:
for i in range(len(word)):
if word[i] == guess:
guessedWord[i] = guess
print('Great guess! Keep going.')
else:
attempts -= 1
print('Wrong guess! Attempts left: ' + str(attempts))
if '_' not in guessedWord:
print('\nCongratulations!! You guessed the word: ' + word)
break
if '_' in guessedWord:
print('\nYou\'ve run out of attempts! The word was: ' + word)