How to reverse the sentence widout changing its way its written..any language preffered . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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")

8th Oct 2017, 9:02 PM
Sixth Sense
Sixth Sense - avatar
7 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/
8th Oct 2017, 9:06 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
8th Oct 2017, 10:09 PM
ReneDaanen
+ 2
and here a solution in c#, using Regex and LINQ https://code.sololearn.com/cOlyOAL6Xc3c/?ref=app
9th Oct 2017, 8:46 AM
ReneDaanen
+ 1
Um, not the best implementation, but one of the shortiest. https://code.sololearn.com/w5Y2dwgVlhlm/?ref=app
8th Oct 2017, 9:13 PM
Freezemage
Freezemage - avatar
8th Oct 2017, 11:58 PM
Schindlabua
Schindlabua - avatar
0
Perl: print join(' ',reverse(split(/\s/,"A reverse test"))); Output: test reverse A
9th Oct 2017, 12:10 AM
Mauricio Lairet
Mauricio Lairet - avatar
11th Oct 2017, 1:21 PM
Siddu Kori
Siddu Kori - avatar