python program for generating diamond pattern in python 3 7 function to print upper half of diamond pyramid print the upper half of a diamond pattern with characters args n int size of the pattern examples floyd3 n n n floyd5 n n n n n function to print lower half of diamond pyramid print the lower half of a diamond pattern with characters args n int size of the pattern examples reversefloyd3 n n n reversefloyd5 n n n n n function to print complete diamond pattern of print a complete diamond pattern with characters args n int size of the pattern examples prettyprint0 nothing printing prettyprint3 n n n n n n python program for generating diamond pattern in python 3 7 function to print upper half of diamond pyramid print the upper half of a diamond pattern with characters args n int size of the pattern examples floyd 3 n n n floyd 5 n n n n n printing spaces printing stars function to print lower half of diamond pyramid print the lower half of a diamond pattern with characters args n int size of the pattern examples reverse_floyd 3 n n n reverse_floyd 5 n n n n n printing stars printing spaces function to print complete diamond pattern of print a complete diamond pattern with characters args n int size of the pattern examples pretty_print 0 nothing printing pretty_print 3 n n n n n n upper half lower half
def floyd(n):
    
    result = ""
    for i in range(n):
        for _ in range(n - i - 1):  
            result += " "
        for _ in range(i + 1):  
            result += "* "
        result += "\n"
    return result



def reverse_floyd(n):
    
    result = ""
    for i in range(n, 0, -1):
        for _ in range(i, 0, -1):  
            result += "* "
        result += "\n"
        for _ in range(n - i + 1, 0, -1):  
            result += " "
    return result



def pretty_print(n):
    
    if n <= 0:
        return "       ...       ....        nothing printing :("
    upper_half = floyd(n)  
    lower_half = reverse_floyd(n)  
    return upper_half + lower_half


if __name__ == "__main__":
    import doctest

    doctest.testmod()