-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
  • 15,602
  • 4
  • 23
  • 52

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
  • 114,268
  • 16
  • 167
  • 218
0

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

Aziz Sonawalla
  • 2,482
  • 1
  • 5
  • 6