Click here to Skip to main content
15,918,889 members

Comments by nate walter (Top 7 by date)

nate walter 4-Nov-21 14:56pm View    
Yeah, I didn't know that
nate walter 4-Nov-21 13:51pm View    
The list is named list_name. It's full of strings. When I run
second_longest = sorted(list_name.split(), key=len)[-2]
I get – AttributeError: 'list' object has no attribute 'split'

When I run
second_longest = sorted(list_name, key=len)[-2]

I get the second longest word returned from the list as desired
nate walter 4-Nov-21 12:22pm View    
That seems to be for a string. I changed it to include the list name in place of "sentence.split" and it did, indeed work @Richard MacCutchan. So the solution looks like:

second_longest = sorted(list_name, key=len)[-2]
nate walter 3-Nov-21 13:31pm View    
If you'd like to post this as a response I'd be more than happy @ Richard MacCuthan
nate walter 3-Nov-21 13:29pm View    
Deleted
import nltk
nltk.download('words')


from nltk.corpus import words
word_list = words.words()
print(len(word_list))
# prints 236736


word_list = word_list
pattern = 'epfdoctlz'

def snellen_words(pattern):
for word in word_list:
find = True
for letter in word:
if letter not in pattern:
find = False
break
if find == True and len(word) > 1:
print(F'The letters of {word} are all in {pattern}')
snellen_words(pattern)