[Tutor] Generating dynamic output

Alan Gauld alan.gauld at btinternet.com
Fri Dec 2 00:46:47 CET 2011


On 01/12/11 23:30, Charles Karl Becker wrote:

> sending this as plain text after the sig, if any indenting is lost
> please let me know and I can send the file

Looks ok to me... a few comments below, the main block
was hurting my hewad so I gave up for now. Its late...

> def build_line(part):
>      ''' dynamically builds and returns the static lines for use in the board '''
>      line = [part for x in range(board_size)]
>      line = ''.join(line)
>      line = line[:-1]
>      return line

You should probably pass in board_size as an argument too.

If you just want to build a string of repeated characters you can use 
multiplication

line = part * board_size

> # defines the board size
> board_size = 5
 > etc/...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list