Code Snippets

  

Linux & UNIX Source Code

  

Python Source Code



Reverse a String

This code snippet reverses a string and then prints it. It uses the slice operator on strings. It steps through the entire string but has a step (optional 3rd parameter) of -1, so that it erturns a backwards String

Submitted By: Dogstopper
Actions:
Rating:
Views: 872

Language: Python

Last Modified: February 9, 2010
Instructions: None! Uses standard Python 2.6

Snippet


  1. string = "This is a String!"
  2. string = string[::-1]
  3. print string

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.