Newbie Question about sequence multiplication

Peter Otten __peter__ at web.de
Thu Apr 5 08:29:46 CEST 2007


Scott wrote:

> sentence = raw_input('Sentence: ')
> 
> screen_width = 80
> text_width = len(sentence)
> box_width = text_width + 6
> left_margin = (screen_width - box_width) // 2
> 
> print
> print ' ' * left_margin + '+'   + '-' * (box_width-2)  +  '+'
> print ' ' * left_margin + '|  ' + ' ' * text_width     + ' |'
> print ' ' * left_margin + '|  ' + ' '   sentence       + ' |'
> print ' ' * left_margin + '|  ' + ' ' * text_width     + ' |'
> print ' ' * left_margin + '+'   + '-' * (box_width-2)  + ' |'
> print

> Now that, even though copied straight from "Beginning Python: From Novice
> to Professional", returns :
> There's an error in your program: invalid syntax

The source code available at 

http://hetland.org/writing/beginning-python/ 

does work.

Peter



More information about the Python-list mailing list