Skip to content
Permalink
Browse files
Create recursive.py
Q3) Recursive program that reads X words from the keyboard and displays it in reverse.
  • Loading branch information
raib10 committed Apr 7, 2021
1 parent 54a40d3 commit 737338bfb42c506f9ba60cc2932c733cf99a11d4
Showing 1 changed file with 10 additions and 0 deletions.
@@ -0,0 +1,10 @@
def reverse_word(x):
if len(x) == 1:
return x
else:
return reverse_word(x[1: ]) + x[0]

x = input("Enter a word to reverse: ")
answer = reverse_word(x)

print("The word",x,"reversed is",answer,".")

0 comments on commit 737338b

Please sign in to comment.