From 533584c4bf2ea12a2a0c14b53efdce003fe4fc29 Mon Sep 17 00:00:00 2001 From: "Bibeak Rai (raib10)" Date: Wed, 7 Apr 2021 14:20:11 +0100 Subject: [PATCH] Update recursive.py Description of code. --- recursive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recursive.py b/recursive.py index 5905bf6..ad693e1 100644 --- a/recursive.py +++ b/recursive.py @@ -1,8 +1,8 @@ def reverse_word(x): - if len(x) == 1: + if len(x) == 1: # If the input word reversed is the same, then input will be printed out as the result. return x else: - return reverse_word(x[1: ]) + x[0] + return reverse_word(x[1: ]) + x[0] # Puts the 0 index of the string at the last index, minus the 0th index the remaining letters will be reveresed. x = input("Enter a word to reverse: ") answer = reverse_word(x)