Python Online Compiler & Playground
HTML/CSS/JavaScript
HTML
CSS
Javascript
C++
C
PHP
Java
Python
Swift
C#
Ruby
Node.JS
Kotlin
jQuery
Go
R
TypeScript
Start Python Course
Register
Reverse words (in place) of sentence (challenge)
+11
Author: Divesh Singh
Dark
Public
Save
PY
py
1
2
3
4
5
6
7
8
9
"""
(Challenge)
Reverses each word in place in a sentence
"""
sentence=
input
(
"Input a string: "
)
print
(
sentence
)
revSentence=
' '
.join
([
word
[::
-1
]
for
word
in
sentence.split
()])
print
(
"Required string: "
,
revSentence
)
Enter to Rename, Shift+Enter to Preview
OUTPUT