Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pname(name: str) -> str:
- name = name .strip().lower()
- while ' ' in name : name = name .replace(' ', ' ')
- name = name .title().split(' ')
- length = len(name)
- if length == 1: return (name[0])
- elif length == 2: return (name[1] + ', ' + name[0])
- elif length == 3: return (name[2] + ', ' + name[0] + ' ' + name[1][0] + '.')
- elif length >= 4: return ' '.join((name[-1] + ',', name[0], ''.join(name[x][0] + '.' for x in range(1, length - 1))))
- print(pname(input()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement