Write a program that takes a string of lowercase characters as input and prints it in uppercase, reversed.
Question
Write a program that takes a string of lowercase characters as input and prints it in uppercase, reversed.
Solution
Sure, here is a simple program that does that:
# Get input from user
input_string = input("Enter a string: ")
# Convert string to uppercase
uppercase_string = input_string.upper()
# Reverse the string
reversed_string = uppercase_string[::-1]
# Print the reversed, uppercase string
print(reversed_string)
This program works as follows:
- It prompts the user to enter a string.
- It converts the string to uppercase using the
upper()
method. - It reverses the string by using slicing with a step of -1, which means start at the end of the string and end at position 0, move with the step -1 (which means one step backwards).
- Finally, it prints the reversed, uppercase string.
Similar Questions
Write a program in C to print a string in reverse using a character pointer.Also print the uppercase of the first letter of the reversed word.
Write a C program to read a sentence and replace lowercase characters with uppercase and vice versa.
Write a C program to read an English Alphabet through keyboard and display whetherthe given alphabet is in upper case or lower case.
How to convert a string str to lowercase characters?Astr.lower()Bstr.toLower()Cstr.toLowerCase()
Write a program to check whether a given character is Alphabet or not using if else statement Note: Check for both upper and lower case characters
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.