Luk4545

Reverse words with basic operations

Nov 1st, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. text = "Hello! Worl'd?"
  2. word = ''
  3. complete = ''
  4.  
  5. for c in text:
  6.     if c in ['!', '?', '.', ',', ' ']:
  7.         complete += word + c
  8.         word = ''
  9.     else:
  10.         word = c + word
  11.  
  12. complete += word
  13. print complete
Advertisement
Add Comment
Please, Sign In to add comment