To Uppercase

Implement a function to_uppercase(c) that converts a lowercase character c to uppercase. If c is not a lowercase character, the function does nothing.

Example:

  • Input: c = 'a'

  • Output: 'A'

  • Input: c = 'A'

  • Output: 'A'

1def to_uppercase(c: str) -> str:
2 if not ('a' <= c <= 'z'):
3 return c
4 return chr(ord(c) - ord('a') + ord('A'))
B
0
s = "B"
s=B
char=B
isLower=false
result=B
Step 1 / 2
Step 1:
If c is not lowercase, return it unchanged.
Focus: default
s="B"char="B"isLower=falseresult="B"