+ 1

Printing the line in reverse

i want to print the line in reverse for example: input is "i am fine" output should be "fine am i"

23rd Jun 2018, 7:36 AM
AISHWARYA KASTHALA
AISHWARYA KASTHALA - avatar
5 ответов
+ 17
list = input().split()[::-1] print(' '.join(list)) It can be done in one line also.. print(' '.join(input().split()[::-1])) Edit:- Thanks Flash didn't know about the reversed()
23rd Jun 2018, 8:05 AM
Frost
Frost - avatar
+ 8
Designing Sorry, About what..?
26th Jun 2018, 9:18 AM
Frost
Frost - avatar
+ 5
another approach: print(' '.join(reversed(input().split())))
23rd Jun 2018, 8:59 AM
Flash
+ 3
Frost u r welcome!
23rd Jun 2018, 3:14 PM
Flash