String Reverse in Python

Posted: November 26, 2008 in Programming, Python, Software
Tags: , , , , ,

One line code to reverse a string in Python:

strOrig = “xyz”

revStr = s[::-1]

where ‘strOrig’ is the source string and ‘revStr’ is the string reversed.

Python is indeed powerful!!

Comments
  1. eli says:

    good thnx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s