Skip to content
Permalink
1f6e0f602e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
10 lines (8 sloc) 432 Bytes
def reverse_word(x):
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] # 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)
print("The word",x,"reversed is",answer,".")