Clean Name




Pay Notebook Creator: Elaine Chan0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0
In [7]:
#crosscompute
s = 'CONNOR, JOHN'
In [8]:
def clean_name(s):
    if ' ' in s:
        s = s.replace(',', '')
        l = s.split()
    else:
        l = s.split(',')
    rl = l[::-1]
    name = (' ').join(rl)
    ti = name.title()
    return ti
In [9]:
result = clean_name(s)
In [10]:
formatted = str(result)
In [11]:
print(formatted)
John Connor
In [12]:
repr(formatted)
Out[12]:
"'John Connor'"
In [13]:
print('{0}'.format(formatted))
print('cleaned_name = {0}'.format(formatted))
John Connor