Python Programming - Console Input/Output - Discussion

Discussion Forum : Console Input/Output - General Questions (Q.No. 68)
68.
How can you read a sentence from the console, find the length of each word, and print the result?
word_lengths(input("Enter a sentence: "))
print_lengths(get_sentence())
sentence = input("Enter a sentence: "); print([len(word) for word in sentence.split()])
lengths = find_word_lengths(get_input_sentence())
Answer: Option
Explanation:
To read a sentence from the console, find the length of each word, and print the result, use sentence = input("Enter a sentence: "); print([len(word) for word in sentence.split()]).
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.