boris-vlasenko

перевернуть порядок слов

Nov 16th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. #~ s = input().split()
  2. #~ s.reverse()
  3. #~ print(' '.join(s))
  4.  
  5. s = input()
  6. s += ' '
  7. s2 = ''
  8. w  = ''
  9. for x in s:
  10.     if x != ' ':
  11.         w += x
  12.     else:
  13.         if w:
  14.             s2 = ' ' + w + s2
  15.             w = ''
  16. print(s2[1:])
Advertisement
Add Comment
Please, Sign In to add comment