-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWord Game.py
44 lines (34 loc) · 1.15 KB
/
Word Game.py
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
# -*- coding: utf-8 -*-
"""Python 102 - Assignment 1
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1-18h7b5KWw3uiTiTqlNvs_a1b-0dOn32
"""
def is_word_guessed(secret_word, letters_guessed):
x = 0
secret_word_list = list(secret_word)
while x != len(secret_word):
if secret_word_list[x] not in letters_guessed:
return False
x = x + 1
return True
# Test the method - True
secret_word = 'python'
letters_guessed = ['y', 't', 'n', 'o', 'p', 'h']
w = is_word_guessed(secret_word, letters_guessed)
print(secret_word, letters_guessed, w)
# Test the method - False
secret_word = 'python'
letters_guessed = ['y', 'q', 'n', 'o', 'p', 'h']
x = is_word_guessed(secret_word, letters_guessed)
print(secret_word, letters_guessed, x)
# Test the method - False
secret_word = 'program'
letters_guessed = ['y', 'q', 'n', 'o', 'p', 'h']
y = is_word_guessed(secret_word, letters_guessed)
print(secret_word, letters_guessed, y)
# Test the method - True
secret_word = 'program'
letters_guessed = ['p', 'm', 'r', 'o', 'g', 'a']
z = is_word_guessed(secret_word, letters_guessed)
print(secret_word, letters_guessed, z)