mardi 11 septembre 2018

How to print pattern in python?

I have coded like this,

size = 5
for i in range(size):
    print ('0' * size)

now it prints,

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

I want to print this pattern in python ,

0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
0 0 1 0 0

Aucun commentaire:

Enregistrer un commentaire