-2

I tried this:

sentence = input("Sentence without punctuation: ")


lst = [sentence]
longestString = max(lst, key=len)
print(longestString)


print(len(longestString))

But my output is this:

sentence = input("Sentence without punctuation: ")


lst = [sentence]
longestString = max(lst, key=len)
print(longestString)


print(len(longestString))
Sayandip Dutta
  • 14,841
  • 3
  • 22
  • 46

2 Answers2

0

If you are trying to break your sentence into words, instead of this

lst = [sentence]

you'd instead want

lst = sentence.split()

Otherwise you are making a list that has a single element, which is your entire string.

Cory Kramer
  • 107,498
  • 14
  • 145
  • 201
0

Simply replace lst = [sentence] with lst = sentence.split()

Aziz Sonawalla
  • 2,412
  • 1
  • 4
  • 6