This is the first CodeSth. I had a towel it has the following pattern:
bgtbl(3, 3, 2, 5) +--+--+--+ | | | | | | | | | | | | | | | | | | | | +--+--+--+ | | | | | | | | | | | | | | | | | | | | +--+--+--+ | | | | | | | | | | | | | | | | | | | | +--+--+--+
Hench this CodeSth’s title, it looks just like a blank grid table.
Write a code which accepts cols rows w h and prints out cols by rows table and each cell is width by height. The cells are separated by -, |, and + like you see in the example above.
Python3
ReplyDeletedef bgtbl(cols, rows, w, h):
s = '+' + '+'.join(['-'*w]*cols) + '+'
print('\n'.join([s] + ([s.translate({43: 124, 45: 32})]*h + [s])*rows))
bgtbl(3, 3, 2, 5)