#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 23 17:43:43 2020 @author: nalshahwan """ #This program draws a diamond. The user specifies the number of levels, they must be #an odd number #For example:a diamond of 5 levels: # # # * # *** #***** # *** # * # #Note: multiplying a string by a number creates a new one that repeats the original #multiple times, for example, '*'*3 = '***' n = int(input('Enter an odd number: ')) if n / 2 != 0: k = 1 while k <= n: print(' '*int((n - k))+'*'*k+' '*int((n * k)/2)) k += 2 j = 1 while (n-2*j) >= 1: print(' ' *j + '*' * (n+2*j) + ' ' * (j)) j += 2 else: print('Not an odd number. Can\'t draw a diamond :(')