Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 475

What built-in functions can I use to improve my code that draws a 3x3 rows and columns and inserts raw numbers 1-9 into the cells?

$
0
0

This is my code

def draw_cell_board(): '''draws 3x3 rows,columns; inserts numbers 1-9 in the cells'''    draw_cell_at_different_range = [(range(1,4)), (range(4,7)),     (range(7,10))]     number_of_rows_in_a_cell = 3     while_loop_counter = 0     while while_loop_counter < number_of_rows_in_a_cell:        print(f'-'*13)        print('| ', end='')        for raw_num in draw_cell_at_different_range[while_loop_counter]:          print(f'{raw_num} | ', end='')          print('') while_loop_counter += 1 # prepare next range      print(f'-'*13)draw_cell_board()

The output is okay. It displays what I want:

-------------| 1 | 2 | 3 | -------------| 4 | 5 | 6 | -------------| 7 | 8 | 9 | -------------

However, I would like to use built-in functions to make my code more pythonic, that is, more professional.


Viewing all articles
Browse latest Browse all 475

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>