Discuss / Python / P1

520bv

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-

#normalize
def normalize(name):
    if not isinstance(name, str):
        raise TypeError('name input is not a string')
    return name[0].upper() + name[1:].lower()

# 测试:
L1 = ['adam', 'LISA', 'barT']
L2 = list(map(normalize, L1))
print(L2)
if L2 == ['Adam', 'Lisa', 'Bart']:
    print('succeed!')
else:
    print('fault!')

  • 1

Reply