lundi 20 septembre 2021

Repeat a line of code without writing it again

      import random
     a = [[random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)],
         [random.randint(1, 1000) for i in range(0, 10)]]

     for i in a:
    for c in i:
        print(c, end = " ")
    print()

that is just a part if my programm. I need 10x10 random generated numbers. Is there a way to write/formate it better. Maybe in less lines.

Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire