print "%s"

Cameron Simpson cs at zip.com.au
Mon Aug 18 08:35:48 CEST 2008


On 18Aug2008 11:58, Beema Shafreen <beema.shafreen at gmail.com> wrote:
| In my script i have to print a series of string , so
| 
| print "%s\t%s\t%s\t%s\t%s\t%s\t" %("a","v","t","R","s","f")
| 
| I need to know instead of typing so many %s  can i write %6s in python, as
| we do in C progm.

I hate to tell you this, but "%6s" in C does NOT print 6 strings. It
prints 1 string, right justified, in no less that 6 characters.
C is just like Python in this example.

| What are the other options .

Write a small loop to iterate over the strings. Print a tab before each
string except the first.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

You see, wire telegraph is a kind of a very, very long cat. You pull his tail
in New York and his head is meowing in Los Angeles. Do you understand this?
And radio operates exactly the same way: you send signals here, they receive
them there. The only difference is that there is no cat.
- Albert Einstein, when asked to describe radio



More information about the Python-list mailing list