AD1

Friday, 11 May 2018

Chess Board

Given two numbers  and . Create a two-dimensional array of size and populate it with the characters "." and "*" in a checkerboard pattern. The top left corner should have the character "." 


above figure shows the main chess board pattern, note that "." means white and "*" means black

n,m = map(int,input().split())
b=[['. ' for x in range(m)]for y in range(n)]
for i in range(n):
for j in range(m):
if(i%2==0 and j%2!=0):
b[i][j]='* '
elif(i%2!=0 and j%2==0):
b[i][j]='* '
for i in range(n):
for j in range(m):
print(b[i][j],end="")
print('\n')
view raw chess board.py hosted with ❤ by GitHub

No comments:

Post a Comment