Feb-20-2022, 11:33 PM
Hi,
my question is quite simple: How would you make this piece of code more simple/efficient?
my question is quite simple: How would you make this piece of code more simple/efficient?
def draw_pattern_1(p,m): print(p, end=' ') print(m, end=' ') print(m, end=' ') print(m, end=' ') print(m, end=' ') print(p, end=' ') print(m, end=' ') print(m, end=' ') print(m, end=' ') print(m, end=' ') print(p) def draw_pattern_2(l): print(l, end=' ') print(l, end=' ') print(l) def draw_grid(f_1,f_2,p,m,l): draw_pattern_1(p,m) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_1(p,m) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_2(l) draw_pattern_1(p,m) p= "+" m = "-" l = "|" draw_grid(draw_pattern_1,draw_pattern_2,p,m,l)
Output:+ - - - - + - - - - +
| | |
| | |
| | |
| | |
+ - - - - + - - - - +
| | |
| | |
| | |
| | |
+ - - - - + - - - - +