Skip to content

Commit 1436b58

Browse files
Add reverse string algorithm in Python
1 parent e2a78d4 commit 1436b58

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

strings/reverse_string.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
A simple program to reverse a string.
3+
4+
Author: Eric Butler Jr.
5+
Date: 2025-10-28
6+
"""
7+
8+
def reverse_string(s: str) -> str:
9+
"""Return the reverse of the given string."""
10+
return s[::-1]
11+
12+
13+
if __name__ == "__main__":
14+
text = input("Enter a string: ")
15+
print("Reversed string:", reverse_string(text))

0 commit comments

Comments
 (0)