Counting words and reversing a string

Report a typo

Imagine you are given a string that represents a sentence or a phrase. Create a program that scans a string as single line input. Your program should print the word count in that string and the reversed string separated by a newline.

Sample Input 1:

Hello World

Sample Output 1:

2
World Hello

Sample Input 2:

Python is fun

Sample Output 2:

3
fun is Python
Write a program in Python 3.10
# We need to create a function that accepts a string as argument
def process_string(s):
# YOUR CODE HERE


# The next line is for invoking the function and you can replace 'your_string_here' with your actual string
process_string('your_string_here')

Create a free account to access the full topic