0

Input should be "one two three" and output should be "three two one".

I tried this but didn't work

s="One Two Three"

ori=s.split(" ")

print(ori)

rev=ori.reverse()

print(rev)
Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
Vivek
  • 322
  • 3
  • 14
  • 5
    Possible duplicate of [How can I reverse a list in python?](http://stackoverflow.com/questions/3940128/how-can-i-reverse-a-list-in-python) – Frank Schmitt Mar 12 '17 at 10:08

1 Answers1

0

You can use Python slice, so the answer to this question is:

>>> rev = ori[::-1]
>>> print(rev)
['Three', 'Two', 'One']

You can learn more about slices here

Community
  • 1
  • 1
WhoKnows
  • 317
  • 1
  • 12