C/C++教程

lowercase_to_uppercase

本文主要是介绍lowercase_to_uppercase,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

python 

char to int: ord(character)

int to char: chr(int_num)

 

Convert a lowercase character to uppercase.

Example 1:

Input: 'a'
Output: 'A'

Example 2:

Input: 'b'
Output: 'B'

 

class Solution:
    """
    @param character: a character
    @return: a character
    """
    def lowercase_to_uppercase(self, character):
        # write your code here
       diff = ord("A") - ord("a")
       return chr(ord(character) + diff)

 

这篇关于lowercase_to_uppercase的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!