, 1. , . , :
word = input('Choose your unknown word: ')
guess = input('guess the first 2 letters corresponding to letters 1 and2 of the unkown word!: ')
1!
2 3 , compute_score. , , :
def compute_score(guess,position,word):
""" Doc string """
score = 0
right_position_value = 100
wrong_position_value = 20
guess = input() <-- This will prompt the user for input a third time, and then
overwrite their initial guess with this one.
position = pos for char in guess <-- Same problem here
word_position = pos for char in word
, . , :
word_position = pos for char in word
, , for , . , for, :
for idx, char in enumerate(word):
(char), , (idx). :
>>> word = 'shape'
>>> for idx, char in enumerate(word):
... print(idx)
...
0
1
2
3
4
, , 3 ( , position , )
2 . , . , . Python "" , :
for char in word:
if char in guess[:2]:
score += 10
.
, , , , , guess score compute_score. :
word = input('Choose your unknown word: ')
guess = input('guess the first 2 letters corresponding to letters 1 and2 of the unkown word!: ')
print('Your guess and score were: ', guess, calculate_score(guess, 0, word))
, 0 position, . , .