jeudi 8 décembre 2022

Dynamic grid using prettytable/tabulate

I want to create a dynamic grid with 2 digits random numbers. The grid will have some empty slots with no numbers, which again randomly generated. If the columns consists of one or more empty spaces from top to bottom "NO" should be display under that columns. If the entire column consists of numbers from top to bottom "OK" should be displayed under that column. The grid size is dynamically passed as a command line argument to the program. If no dimensions are passed, the default dimension for the grid is 5x5. The lowest dimensions must be 3x3 while the highest dimension must be 9x9. Some possible commands would be, • C:>perc 3x4

  1. The above creates a 3x4 grid • C:>perc
  2. The above creates a 5x5 default grid

This is what I tried,

nums = [] for i in range(3): nums.append([]) for j in range(1, 4): nums[i].append(j) print("3X3 grid with numbers:") print(nums)

How can I do this question?



Aucun commentaire:

Enregistrer un commentaire