E.g:
input: I live in New York
output: York New in live I
P.S: I have used s[::-1]
, this just reverses the string, like
kroY weN ni evil I
, but this is not the desired output.
I also tried :
def rev(x) :
x = x[::-1]
for i in range(len(x)) :
if x[i] == " " :
x = x[::-1]
continue
print x
But this also stands incorrect.
Kindly help me in writing the code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…