Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. from itertools import zip_longest
  2. def myfunc(s):
  3. return ''.join(map(''.join, zip_longest(s[::2].upper(), s[1::2], fillvalue='')))
  4.  
  5. print(myfunc('Hello World'))
  6.  
  7. def myfunc(str):
  8. new_str = ''
  9. for index,char in enumerate(str):
  10. if index % 2 == 0:
  11. new_str += char.upper()
  12. else:
  13. new_str += char
  14. return new_str
  15.  
  16. print(myfunc('Hello World'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement