Upper case conversion Python

PROGRAM TO CONVERT LOWER CASE CHARACTERS TO UPPER CASE CHARACTERS



# Converts a string to uppercase
def to_upper(string):
    for i in range(len(string)):
        if ('a' <= string[i] <= 'z'):
            string = (string[0:i] + chr(ord(string[i]) - 
                                        ord('a') + ord('A')) +
                                        string[i + 1:])
    return string;
  
# Driver code
if __name__ == '__main__':
    str = "geeksforgeeks";
    print(to_upper(str));


OUTPUT
GEEKSFORGEEKS

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java