Given two numbers and . Create a two-dimensional array of size and populate it with the characters
above figure shows the main chess board pattern, note that "." means white and "*" means black
"."
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
No comments:
Post a Comment