Write a program to pass a string to a function.return and print reverse of it
def reverse(n):
n1=""
for i in n:
n1=i+n1
print("Reverse ",n1)
def main():
n=input("Enter any string ")
reverse(n)
"""
if __name__=='__main__':
main()
"""
#or
#function calling
main()
Output:-
(1). Enter any string apple
Reverse elppa
(2). Enter any string bat
Reverse tab
(3). Enter any string computer
Reverse retupmoc
No comments:
Post a Comment