Python Exercise: Reverse a word
5. Reverse a Word
Write a Python program that accepts a word from the user and reverses it.
Pictorial Presentation:

Sample Solution:
Python Code:
# Prompt the user to input a word
word = input("Input a word to reverse: ")
# Iterate through the characters of the word in reverse order
for char in range(len(word) - 1, -1, -1):
# Print each character from the word in reverse order without a new line (end="")
print(word[char], end="")
# Print a new line to separate the reversed word from the next output
print("\n")
Sample Output:
Input a word to reverse: ecruoser3w w3resource
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to reverse a word entered by the user using slicing.
- Write a Python program to reverse each word in a sentence while maintaining the word order.
- Write a Python program to recursively reverse a given string without using slicing.
- Write a Python program to reverse a word using a stack data structure to simulate character popping.
Go to:
Previous: Write a Python program to construct the following pattern, using a nested for loop.
Next: Write a Python program to count the number of even and odd numbers from a series of numbers.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.