Python Exercise: Reverse a word

Python Conditional: Exercise-5 with Solution

Write a Python program that accepts a word from the user and reverse it.

Pictorial Presentation:

Python Exercise: Reverse a word

Sample Solution:

Python Code:

word = input("Input a word to reverse: ")

for char in range(len(word) - 1, -1, -1):
  print(word[char], end="")

Sample Output:

Input a word to reverse: ecruoser3w  


Flowchart: Python program that accept a word from the user and reverse it

Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

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.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

Python: Tips of the Day

Returns a list with n elements removed from the beginning


def tips_take(itr, n = 1):
  return itr[:n]
print(tips_take([1, 2, 3], 5))
print(tips_take([1, 2, 3], 0))


[1, 2, 3]