# -*- 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!')
Sign in to make a reply
520bv