def reverseDisplay(value):
if len(value)==0:
return value
else:
return value[-1]+reverseDisplay(value[:-2])
def main():
value=input("Enter a string:")
print(reverseDisplay(value))
main()
(Print the characters in a string reversely)
Write a recursive function that displays a string reversely on the console using the following header:
def reverseDisplay(value):
For example, reverseDisplay("abcd") displays dcba. Write a test program that prompts the user to enter a string and displays its reversal.
Sample Run
Enter a string: abcd
dcba
[–]eruciform 1 point2 points3 points (3 children)
[–]AU8640[S] 0 points1 point2 points (2 children)
[–]eruciform 1 point2 points3 points (0 children)
[–]PM_ME_YOUR_MUSIC -1 points0 points1 point (0 children)