mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
b345ea586f
commit
f815dff201
@ -1,13 +1,14 @@
|
|||||||
"""
|
"""
|
||||||
To find the smallest and largest word in the sentence
|
To find the smallest and largest word in the sentence
|
||||||
Example
|
Example
|
||||||
if the input string is
|
if the input string is
|
||||||
My name is abc
|
My name is abc
|
||||||
then the output will be
|
then the output will be
|
||||||
The smallest word in the given string is be
|
The smallest word in the given string is be
|
||||||
The largest word in the given string is output
|
The largest word in the given string is output
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def find_smallest_and_largest_words(input_string):
|
def find_smallest_and_largest_words(input_string):
|
||||||
words = input_string.split()
|
words = input_string.split()
|
||||||
if not words:
|
if not words:
|
||||||
@ -18,6 +19,7 @@ def find_smallest_and_largest_words(input_string):
|
|||||||
|
|
||||||
return smallest_word, largest_word
|
return smallest_word, largest_word
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
input_string = input("Enter a string here:\n").strip()
|
input_string = input("Enter a string here:\n").strip()
|
||||||
smallest, largest = find_smallest_and_largest_words(input_string)
|
smallest, largest = find_smallest_and_largest_words(input_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user