Discuss / Python / 第一题:名字规范

第一题:名字规范

Topic source

lianwade3

#1 Created at ... [Delete] [Delete and Lock User]

!/usr/bin/env python3

-- coding: utf-8 --

def normalise(s): return s.capitalize()

L=['adam', 'LISA', 'barT']

N=list(map(normalise, L)) print(N)

水滴竹沙

#2 Created at ... [Delete] [Delete and Lock User]

def normalize(x) : return x[:1].upper()+x[1:].lower()

youzhoutaiV

#3 Created at ... [Delete] [Delete and Lock User]

这个结果能帮解释下是为什么不对的吗? return [x[:1].upper()+x[1:].lower() for x in name]


  • 1

Reply