Python program to reverse a string

You can reverse a string in Python using slicing. Here's a simple Python program to reverse a given string:


def reverse_string(string):

# Using slicing to reverse the string

return string[::-1]

# Example usage:

input_string = input("Enter a string: ")

reversed_string = reverse_string(input_string)

print("Reversed string:", reversed_string)


This program prompts the user to input a string, and then it reverses the string using slicing and prints the reversed string.