Python
  Home arrow Python arrow Page 4 - Python: Stringing You Along
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PYTHON

Python: Stringing You Along
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2008-01-28


    Table of Contents:
  • Python: Stringing You Along
  • Making Text Appear Exactly As You Typed It
  • Other Ways to Span Text
  • String Operators

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Python: Stringing You Along - String Operators
    ( Page 4 of 4 )

    There are several operators you can use on strings. Here is how some of them work:


    #!/usr/local/bin/python

    first ="James "

    last ="Payne "

    truth ="Is a bad mamma jamma"

    print "Here is an example of concatenating string variables:"

    print first+last+truth

    print "n"

    print "Here is another example of concatenating strings:"

    print "I like it " + "When you call me " + "Big Poppan "

    print "And here is an example of how to repeat text with variables:"

    print first *3

    print "You can also print it on three separate lines:"

    print (first + "n") * 3

    print "You can also concatenate and repeat (as we did above):"

    print (first+last+truth+ "n") * 4

    Note that I put a space in my strings. If I had not, the words would be bunched together. Here is the result:

      Here is an example of concatenating string variables:

      James Payne Is a bad mamma jamma

      Here is another example of concatenating strings:

      I like it When you call me Big Poppa

     

      And here is an example of how to repeat text with variables:

      James James James

      You can also print it on three separate lines:

      James

      James

      James

      You can also concatenate and repeat (as we did above):

      James Payne Is a bad mamma jamma

      James Payne Is a bad mamma jamma

      James Payne Is a bad mamma jamma

      James Payne Is a bad mamma jamma

    Well that's it for this tutorial. We still have more string-a-ma-things to cover, and we will do so in the next article. So come back often and get dat learn on son.

    Till then...



     
     
    >>> More Python Articles          >>> More By James Payne
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek