Skip to content
Snippets Groups Projects
pyramid.py 661 B
Newer Older
  • Learn to ignore specific revisions
  • #!/usr/bin/env python3
    
    
    import sys
    
    
    Markus Opolka's avatar
    Markus Opolka committed
    def is_even(n):
    
    Markus Opolka's avatar
    Markus Opolka committed
        if n % 2 == 0:
            return True
        else:
            return False
    
    
    def draw_pyramid(size):
    
        if is_even(size):
            print("Bitte nur ungerade! Du Horst.")
            return
    
        height = 1
    
        while (height < size):
            print("=" * height)
            height = height + 1
    
        while (height > 0):
            print("=" * height)
            height = height - 1
    
    
    def main(args):
    
        try:
            height = int(args[0])
            draw_pyramid(height)
        except Exception as e:
            print('Please specify pyramid height')
            print(e)
    
    if __name__ == '__main__':
    
        args = sys.argv[1:]
        main(args)