Exp 5 python

0

 Create a program that prompts the user for a string and then prints out the string reversed. 


USING LOOP


string = input("Enter a string: ")

reversed_string = ""


for char in string:

    reversed_string = char + reversed_string


print("Reversed string:", reversed_string)


USING SLICE


string = input("Enter a string: ")

reversed_string = string[::-1]

print("Reversed string:", reversed_string)


Post a Comment

0Comments

GUYS IF YOU HAVE ANY DOUBT. PLEASE LET ME KNOW

Post a Comment (0)