Newbie, homework help, please.
BartC
bc at freeuk.com
Sat Apr 21 16:38:41 EDT 2012
More information about the Python-list mailing list
Sat Apr 21 16:38:41 EDT 2012
- Previous message (by thread): Newbie, homework help, please.
- Next message (by thread): Newbie, homework help, please.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"someone" <wesbroom at gmail.com> wrote in message news:4068590.2196.1335038608255.JavaMail.geo-discussion-forums at ynjn4... >> textTuple = border(SHI) >> for lines in textTuple: >> print (lines) > > Thanks your Bart for trying, I don't understand how it works or if you > tried to place my script in python to see if it would work, unfortunately, > I tried 10 different ways plus yours, and I don't see the connection. > Unless you were trying to help me see the way and I did not, sorry, but > thanks for trying. The characters did show me a little more. Did you run my code fragment on it's own to see if it did the job? The code can be packaged into a function border() just like you already have: def border(text): maxwidth=0 for s in text: if len(s)>maxwidth: maxwidth=len(s) vertinchlines=6 # assume 6 lines/inch hozinchchars=10 # assume 10 chars/inch hozmargin=" "*hozinchchars newtext=[] for i in range(vertinchlines): newtext.append("") newtext.append(hozmargin+"*"*(maxwidth+4)+hozmargin) newtext.append(hozmargin+"* "+" "*maxwidth+" *"+hozmargin) for s in text: newtext.append(hozmargin+"* "+s+" "*(maxwidth-len(s))+" *"+hozmargin) newtext.append(hozmargin+"* "+" "*maxwidth+" *"+hozmargin) newtext.append(hozmargin+"*"*(maxwidth+4)+hozmargin) for i in range(vertinchlines): newtext.append("") return newtext And can be tested like this (obviously you will need to obtain SHI from the input file): SHI=["First Name and Last","ENGR 109-X","Fall 2999","Format Example"] textTuple = border(SHI) for lines in textTuple: print (lines) The text handling is clunky (I had to learn the Python as I went along), but with these things you just want to get something working first, then you can tweak. -- Bartc
- Previous message (by thread): Newbie, homework help, please.
- Next message (by thread): Newbie, homework help, please.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list