Convert all lowercase letters to uppercase letters in python; Through this tutorial, you will learn how to convert all lowercase letters to uppercase letters or characters or string in python.
Python has many built-in functions/methods for manipulation with strings, which you can check here (python string methods).
1: Convert lowercase to uppercase in python with using the function
You can use the python string method/function that name upper(), This method converts all letters or characters of string lowercase to uppercase.
The syntax of upper() method is:
string.upper()
String upper() Parameters()
The upper() method doesn’t take any parameters.
Return value from String upper()
The upper() method returns the uppercased string from the given string. It converts all lowecase characters to uppercase.
If no lowercase characters exist, it returns the original string.
Example 1: write a program to convert all lowercase to uppercase characters in python
# example string string = "This is first example of convert string lowercase to uppercase" print(string.upper()) #Output #THIS IS FIRST EXAMPLE OF CONVERT STRING LOWERCASE TO UPPERCASE
2: How to convert lowercase to uppercase in python without using string function
As you have seen in the example given above, we have done how to convert all the letters of string from lowercase to uppercase by using the upper() method of Python.
To write a program in Python that will convert all the letters of the string from lowercase to uppercase without using any Python function:
# convert lowercase to uppercase in python without using function st = 'how to convert lowercase to uppercase in python without using string function' out = '' for n in st: if n not in 'abcdefghijklmnopqrstuvwqxyz': out = out + n else: k = ord(n) l = k - 32 out = out + chr(l) print('------->', out)
The output of above python program is:
HOW TO CONVERT LOWERCASE TO UPPERCASE IN PYTHON WITHOUT USING STRING FUNCTION
Recommended Python Tutorials
- Python Program to Convert Uppercase to Lowercase
- Python First Character of String Uppercase
- Python Concatenate String and Variable (int, float, etc)
- How to Find Length of String in Python
- Python: String Join Function
- Python String Append Examples
- How to replace a character in a string in python
- Python – Count Number of Occurrences in String
- Python Remove Last Character from String
- Python Remove Character From String
- Python Program to Reverse String
- Python Program to Remove First Occurrence of Character in a String
- Python: Remove Special Characters from String
- Python Program Count vowels in String
- Python Split a String into Array of Characters, Space
- Python Program to Swap Two Character of Given String
- Python Program String Find
- Python: Two Given Strings and Swap First Two Characters of Each String
- Print All Permutations of Given String in Python
- Python | Check Whether a String Contains Number or Letter
- Python: Convert String to Float & Float to String
- Python Program to Reverse String Using Stack
- How To Convert Python Int to String and String to Int
- Python Convert String to List and List to String
It was good to learn from this website, But it would have been great if you have provided a video for better understanding of the concept….