# Python program to find number of words in a sentence my_str = input("Enter a string : ") # display the original string print("The original string is : ", my_str) #find the length of split words words= len(my_str.split()) print("The number of words in given string are : ",words)
Output:
Enter a string : Rama and Vedanshi are good friends The original string is : Rama and Vedanshi are good friends The number of words in given string are : 6