Sentence Length

Write a program that asks the user for five words that will make up a sentence. The sentence should then be created and its length stored as a variable. Finally, the sentence and its length should be displayed to the user.

Enter the first word: Studying
Enter the second word: will
Enter the third word: lead
Enter the fourth word: to
Enter the fifth word: success
The sentence ' Studying will lead to success ' has  29 characters.
DECLARE word1, word2, word3, word4, word5, sentence AS STRING
DECLARE length AS INTEGER

OUTPUT "Enter the first word: "
INPUT word1
OUTPUT "Enter the second word: "
INPUT word2
OUTPUT "Enter the third word: "
INPUT word3
OUTPUT "Enter the fourth word: "
INPUT word4
OUTPUT "Enter the fifth word: "
INPUT word5

SET sentence TO word1 + " " + word2 + " " + word3 + " " + word4 + " " + word5

SET length TO LENGTH(sentence)

OUTPUT "The sentence '", sentence, "' has ", length, " characters."

word1 = str(input("Enter the first word: "))
word2 = str(input("Enter the second word: "))
word3 = str(input("Enter the third word: "))
word4 = str(input("Enter the fourth word: "))
word5 = str(input("Enter the fifth word: "))

sentence = word1 + " " + word2 + " " + word3 + " " + word4 + " " + word5

print("The sentence '", sentence, "' has ", len(sentence), "characters.")
# Get five words from the user
word1 = str(input("Enter the first word: "))
word2 = str(input("Enter the second word: "))
word3 = str(input("Enter the third word: "))
word4 = str(input("Enter the fourth word: "))
word5 = str(input("Enter the fifth word: "))

# Combine all five words into a sentence
sentence = word1 + " " + word2 + " " + word3 + " " + word4 + " " + word5

# Display the sentence and its length to the user
print("The sentence '", sentence, "' has ", len(sentence), "characters.")

Extension

Extend the program to get a second five-word sentence from the user. Both sentences should be displayed to the user, along with the combined total lengths.

Enter the first word: Studying
Enter the second word: will
Enter the third word: lead
Enter the fourth word: to
Enter the fifth word: success
The sentence ' Studying will lead to success ' has  29 characters.
Enter the first word: Regular
Enter the second word: studying
Enter the third word: helps
Enter the fourth word: pass
Enter the fifth word: exams
The sentence ' Regular studying helps pass exams ' has  33 characters.
Total length of sentences 62

Target

You should be able to use the Length predefined function to solve a problem.