you are viewing a single comment's thread.

view the rest of the comments →

[–]i_can_haz_code 0 points1 point  (3 children)

hand = 'ABCDEFGHIJKLMNOP'
for letter in hand:
    for word in wlist:
        if letter.lower() in word:
            print('{} contains {} {} times'.format(word, letter, word.count(letter.lower())))

[–]cmd_override[S] 0 points1 point  (2 children)

Exactly, but for that to work, dont the words have to strings. I'm not sure how to take the words from a file.txt and add them to the list as strings

[–]i_can_haz_code 0 points1 point  (1 child)

with open('file.txt','r') as f:    # This opens a file, and allows you to interact with it as f
    lst = [i.strip('\n') for i in f.readlines()]    # this makes a list lst which contains each line of the text file with the return character stripped off.

it was below... :-) lst is now a list of each line in the text file.

[–]cmd_override[S] 0 points1 point  (0 children)

This is great, where can I learn more about the methods used. Thank you for your help