4 Replies - 6689 Views - Last Post: 12 October 2011 - 02:41 PM Rate Topic: -----

#1 jubiKaL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-October 11

how do you print two columns in python?

Posted 11 October 2011 - 07:01 PM

I originally wrote this in freebasic and wanted to convert it to python.
when i run it it will only print the first column.
I've checked the tutorials but have made no headway.
a1 = "john"
a2 = "cleese"
b1 = "michael"
b2 = "palin"
c1 = "terry"
c2 = "jones"
d1 = "graham"
d2 = "chapman"
e1 = "eric"
e2 = "idle"
f1 = "terry"
f2 = "gilliam"

print "Monty Python"

print

print

print "first name"  "last name"

print "----------" "---------"

print a1; a2

print b1; b2

print c1; c2

print d1; d2

print e1; e2

print f1; f2

print
print
print "NI!"



thanks

Is This A Good Question/Topic? 0
  • +

Replies To: how do you print two columns in python?

#2 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 319
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: how do you print two columns in python?

Posted 11 October 2011 - 07:32 PM

I think you were meaning to do:

print a1, a2



Semi-colons are not used a lot in Python, and they don't need to be. What happen is you are printing the first value and then just calling the second variable by name, so it won't print anything.

Are you considering using a dictionary or something to store the data? It could be much more flexible and concise.
Was This Post Helpful? 0
  • +
  • -

#3 jubiKaL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-October 11

Re: how do you print two columns in python?

Posted 11 October 2011 - 07:42 PM

thank you
Was This Post Helpful? 0
  • +
  • -

#4 ATC3  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 54
  • Joined: 04-October 11

Re: how do you print two columns in python?

Posted 12 October 2011 - 02:34 PM

Thank you as well it helped me too.
Was This Post Helpful? 0
  • +
  • -

#5 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 319
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: how do you print two columns in python?

Posted 12 October 2011 - 02:41 PM

No problem :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1