def LongestWord(sen):
# first we remove non alphanumeric characters from the string
# using the translate function which deletes the specified characters
sen = sen.translate(None, "~!@#$%^&*()-_+={}[]:;'<>?/,.|`")
# now we separate the string into a list of words
arr = sen.split(" ")
print(arr)
# the list max function will return the element in arr
# with the longest length because we specify key=len
return max(arr, key=len)
**print LongestWord("Argument goes here")**
这条线有什么问题?我怎样才能改变它?我无法理解!这让我真的很不安,因为在 Coderbyte.com 上说这是真的,而且有效!
慕婉清6462132
相关分类