Given an integer N, write a program to print the hollow diamond pattern in 2*N rows and 2*N columns, similar to the pattern shown below
def diamond(n):
for i in range(n):
s = [' ']*n
s[n-1-i] = '*'
s = s + s[::-1]
s = ''.join(s)
print(s)
for i in range(n):
s = [' ']*n
s[i] = '*'
s = s + s[::-1]
s = ''.join(s)
print(s)
def main():
n = int(input('Enter a number N '))
diamond(n)
if __name__ == '__main__':
main()
Comments
Leave a comment