Newbie, homework help, please.

Kiuhnm kiuhnm03.4t.yahoo.it
Sat Apr 21 17:31:28 EDT 2012


On 4/21/2012 22:26, GrayShark wrote:
> -----------------------
> #!/usr/bin/python
>
>
> xl = ["First Name and Last","ENGR 109-X","Fall 2999","Format Example"]
>
> xl_max = 0
> for x in xl:
> 	xl_max = max ( len( x ), xl_max )

Or
   xl_max = max([len(x) for x in xl])

> topBorder = '^'*( xl_max + 4 )
>
> print topBorder
> for x in xl:
> 	print "* %s%s *" % ( x, ' '*(xl_max - len( x )) )

Or
   print "* %-*s *" % (xl_max, x)

I hope you don't mind.

Kiuhnm



More information about the Python-list mailing list