SSB
SSB

Reputation: 69

How to properly format Python Print with multiple parameters?

Currently I am getting the following output:

data1     57578896
data2     57695876
anotherdata     59859485

What formatting do I add, so that it will look something like this:

data1          57578896
data2          57695876
anotherdata    59859485

What I have now looks like this:

print "%s     %d" % (input_list[i], data)

Upvotes: 1

Views: 59

Answers (1)

Stephen Rauch
Stephen Rauch

Reputation: 49804

Use a width specifier like:

print "%-14s%d" % (input_list[i], data)

Upvotes: 1

Related Questions