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)

 

posted @ 2022-05-10 22:20  7aughing  阅读(30)  评论(0编辑  收藏  举报