Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # text_incr.py
- def incr_str(s):
- p = s.rstrip('z')
- r = len(s) - len(p)
- if p: p = p[:-1] + chr(ord(p[-1]) + 1)
- else: p = 'a'
- p += 'a' * r
- return p
- #
- print incr_str('aaa')
- print incr_str('zzz')
- print incr_str('a')
- print incr_str('z')
- print incr_str('pizzazz')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement