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

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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? 
PYTHON

Python: Stringing You Along
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Lose your application development headaches. Start developing and deploying applications with Advantage Database Server today. Download a 30-day trial for Free!

    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...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Thanks for dropping by to read my article on Python strings. In this episode we...
       · Thanks for the article, but the text spanning examples are broken. The backslashes...
       · Hey, thanks for catching that; our content system sometimes gobbles up our...
       · I fixed the article as well. Thanks.-James Payne
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway