+ 3
How to reverse the sentence widout changing its way its written..any language preffered .
For e.g. Input ("I love my India") Output ("India my love I")
8 Answers
+ 13
sent = "I like London in the rain"
print(' '.join(sent.split()[::-1]))
>>>
rain the in London like I
https://code.sololearn.com/c2zzFd0a1I9Q/
+ 3
this is a solution in c#
https://code.sololearn.com/c8m7CmG2WwRp/?ref=app
+ 2
and here a solution in c#, using Regex and LINQ
https://code.sololearn.com/cOlyOAL6Xc3c/?ref=app
+ 1
Um, not the best implementation, but one of the shortiest.
https://code.sololearn.com/w5Y2dwgVlhlm/?ref=app
+ 1
Haskell:
main = interact $ unwords . reverse . words
https://tio.run/##HchBEkAwDAXQq/yFtRu4gFtEBRnVklSLy5exe/MWspW9r3UjCeggIbGSS2hwhhJ1NLRQzqzGn/6ptSe3jlQMPmbGdmOQGbYvEi7ECcdJmp4X
0
Perl:
print join(' ',reverse(split(/\s/,"A reverse test")));
Output: test reverse A