Riju21

28_prac_9_replace_even_odd_reverse word

Mar 29th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. #replace even digit with increment 1 & odd with less 1
  2. # -----------------------------------------------------
  3.  
  4. # numbers = [231, 117, 0, 8341, 46709]
  5.  
  6. # def check(i):
  7. #     li = list(str(i))
  8. #     toInt = list(map(int, li))
  9. #     for x in toInt:
  10. #         if x % 2 == 0:
  11. #             x += 1
  12. #         elif x % 2 != 0:
  13. #             x -= 1
  14. #         print(x, end='')
  15. #     print('\n')    
  16. # for i in numbers:
  17. #     check(i)
  18.  
  19. # reverse word
  20. # ---------------------------
  21.  
  22. words = ['sun rises in the east', 'hello world']
  23.  
  24. def check(li):
  25.     x = li.split(' ')
  26.     x.reverse()
  27.     for i in x:
  28.         print(i, end=' ')
  29.     print('\n')    
  30. for i in words:
  31.     check(i)
Advertisement
Add Comment
Please, Sign In to add comment