Convert all uppercase to lowercase in a word

In this program, we will take a word as input from the user and convert all uppercase to lowercase in a word.

Steps to solve the program
  1. Take a word as input from the user.
  2. Use for loop to iterate over each character of the word.
  3. Check whether the character is uppercase or not using isupper().
  4. If it is an uppercase character convert it to lowercase using lower().
  5. Print the output.
Solution 1 :
				
					input1 = input("Enter word: ")
result = ''
for char in input1:
    if char.isupper():
        print(char.lower(),end="")
    else:
        print(char,end="")
				
			
Output :
				
					Enter word: SQATOOLS
sqatools
				
			
Solution 2 :
				
					str1 = input("Enter input string:")
result = ""
for char in str1:
    # get character ascii value 
    char_ascii = ord(char)
    # check ascii value between 65 - 90 range
    # then character is in upper case
    if 65 <= char_ascii <= 90:
        # get character exact location
        char_position = char_ascii - 65
        # convert upper char ascii to lower case.
        # add character to the result
        result = result + chr(97+char_position)
    else:
        result = result + char

print("Result :", result)
				
			
Output
				
					Enter Input String: SQATOOLS Learning
Result : sqatools learning
				
			

Fizz-Buzz Program

accepts a string and calculates the number of digits and letters

Leave a Comment