Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse object value with reversed() in python3 #474

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,9 @@ Name: [antoooks](https://github.com/antoooks) </br>
Place: Indonesia / Singapore </br>
Coding Experience: JS, TS, PHP, Java, Go. Specialize in CI/CD, Cloud Architecture, and Automation.
Email: antokurnianto82@gmail.com </br>

Name: [Arjun Khunti](https://github.com/ArjunKhunti) </br>
Place: India </br>
Field Experience: Software Engineer </br>
Coding Experience: Js, React, Python and Dart, Good in CI/CD and Automation. </br>
Email: arjunvkhunti@gmail.com </br>
18 changes: 18 additions & 0 deletions python/reverse/arjunkhunti_strrev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
python3 has reversed() funtion which returns an iterator
that accesses the given sequence in the reverse order

more details: https://docs.python.org/3/library/functions.html#reversed
"""

# Reverse string
TEST_STR = "I love Hacktoberfest"
print(f"Reversed String : {''.join(reversed(TEST_STR))}")

# Reverse List
TEST_LIST = ["I", "love", "Hacktoberfest"]
print(f"Reversed List : {list(reversed(TEST_LIST))}")

# Reverse Tuple
TEST_TUPLE = ("I", "love", "Hacktoberfest")
print(f"Reversed Tuple : {tuple(reversed(TEST_TUPLE))}")