说明: 第一步是编写一个函数lower char(char),它可以返回将单个字符字符转换为小写字符的结果。它应该执行以下操作:
if the input character char is a capital letter (between 'A' and 'Z'), it should return the lower-case version of the letter (between 'a' and 'z'). In all other cases, it should return the same char which was input.
(要执行第一步,必须使用if语句、and运算符,并应用有关字符串的课程中的一些知识。)
我只有-
def lowerChar(char):
第二行和第三行是可选的,只需确保传入的值实际上是单个字符串,而不是多个字符串。
最好不要使用硬编码常量
另一种没有
chr
和ord
的方法所以你想要的是:
或者,您可以使用下面这样的ascii值:
相关问题 更多 >
编程相关推荐