例如:
input: I live in New York
output: York New in live I
Run Code Online (Sandbox Code Playgroud)
PS:我用过s[::-1],这只是反转字符串
kroY weN ni evil I,但是这不是所需的输出.我也尝试过:
def rev(x) :
x = x[::-1]
for i in range(len(x)) :
if x[i] == " " :
x = x[::-1]
continue
print x
Run Code Online (Sandbox Code Playgroud)
但这也是不正确的请帮助我编写代码.
python-2.7 ×1