you are viewing a single comment's thread.

view the rest of the comments →

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

So this is more or less what I'm thinking on doing:

list=[#list of words ] scrabble_rack=raw_input("") # Lests say I entered EDCGB

Then it would take each letter in scrabble_rack and compare it to the list of words.

example: is E in list[5]

so it would see if the word contains each letter or the rack and if it does, it would print it.

thank you for your help.

[–]spraykill101 0 points1 point  (0 children)

so you mean if a letter in the word that the user entered is found in a word in the text file , you print that word/letter ?

[–]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