Reverse a string: Difference between revisions
Content added Content deleted
(Easy!) |
m (corrected header) |
||
Line 2: | Line 2: | ||
Take a string and reverse it. For example, "asdf" becomes "fdsa". |
Take a string and reverse it. For example, "asdf" becomes "fdsa". |
||
==Python== |
=={{header|Python}}== |
||
===Optimized for user input=== |
===Optimized for user input=== |
||
<pre>raw_input()[::-1]</pre> |
<pre>raw_input()[::-1]</pre> |
Revision as of 21:49, 18 April 2008
Reverse a string
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Take a string and reverse it. For example, "asdf" becomes "fdsa".
Python
Optimized for user input
raw_input()[::-1]
Already known string
string[::-1]