Python: Display an input string in upper and lower cases
Python String: Exercise-13 with Solution
Write a Python script that takes input from the user and displays that input back in upper and lower cases.
Sample Solution:
Python Code:
# Prompt the user to enter their favorite language and store the input in the variable 'user_input'.
user_input = input("What's your favorite language? ")
# Print the message "My favorite language is" followed by the user's input converted to uppercase.
print("My favorite language is ", user_input.upper())
# Print the message "My favorite language is" followed by the user's input converted to lowercase.
print("My favorite language is ", user_input.lower())
Sample Output:
What's your favourite language? english My favourite language is ENGLISH My favourite language is english
Flowchart:
Python Code Editor:
Previous: Write a Python program to count the occurrences of each word in a given sentence.
Next: Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form (alphanumerically).
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/python-exercises/string/python-data-type-string-exercise-13.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics