I am writing a code for the game hangman. I am stuck in the part where I want to help the user to get a hint.
I need to create a function that accepts a word list
, and the current pattern
(for example:"___e_") and returns the most common letter
in the word list.
I know I need to count the letters in each word and then return the maximum of that letter list but I don't quite know how to actually perform this.
I started by writing this code:
def choose_letter(words, pattern):
new_list = [0] * 26
for i in range(0, 26):
for n in range(0, len(num_list)):
if i == num_list[n]:
new_list[i] += 1
return new_list
but I get stuck because I don't know how to actually compare it to a letter.
I would love to hear some advice or guidance that will help me proceed.
*we didnt learn about dictionary yet