Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def to_lower(s):
- return s.lower()
- def to_upper(s):
- return s.upper()
- def process_chr(s, fn=to_upper):
- if len(s) == 0:
- return ""
- char = s[0]
- if char.isalpha():
- return fn(char) + process_chr(s[1:], to_lower if fn == to_upper else to_upper)
- elif char in (".", "!", "?"):
- return char + process_chr(s[1:], to_upper)
- else:
- return char + process_chr(s[1:], fn)
- if __name__ == '__main__':
- print(process_chr(sys.argv[1]))
Add Comment
Please, Sign In to add comment