DEV Community

Discussion on: Challenge of making a diamond of numbers

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited
def main():
    n = int(input("Input any number : "))
    print_diamond(n)

def print_diamond(n):
    s = str(int('1'*n)**2)
    f = '%'+str(n-1)+'s'
    for i in map(int,s):print f%s[:i-1]+s[-i:]

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode
Collapse
 
daftyw profile image
daftyw

Nice to having you on this post 👋🙂

Collapse
 
codefinity profile image
Manav Misra

And nice to have you join our community and partcipatd! 🤓