Python Practice › String Programs › Program 98

Reverse the words

EasyString Programs · 98 of 106

Write a Python program to reverse the order of words.

Advertisement
Input
"string problems"
Output
problems string

Approach

  1. " ".join(reversed(text.split())).

Solution

Python
print(" ".join(reversed("string problems".split())))
Output
problems string
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs