PythonReverse string in Python

def reverse_string(s):
    return s[::-1]
    string = "Hello, World!"
reversed_string = reverse_string(string)
print(reversed_string)

Related Snippets

Cover Image for Define a class and create an object in Python

Define a class and create an object in Python

Loading...
Cover Image for Dictionary Comprehension in Python

Dictionary Comprehension in Python

Loading...
Cover Image for Efficiently read a file with Python

Efficiently read a file with Python

Loading...
Cover Image for Error Handling in Python

Error Handling in Python

Loading...
Cover Image for Generate a list in a single line of code in Python

Generate a list in a single line of code in Python

Loading...
Cover Image for Lambda Function in Python

Lambda Function in Python

Loading...