HackerRank- Python Alphabet Rangoli




You are given an integer N

. Your task is to print an alphabet rangoli of size N

. (Rangoli is a form of Indian folk art based on creation of patterns.)
Different sizes of alphabet rangoli are shown below:



  1. def print_rangoli(size):
  2. import string
  3. alpha = string.ascii_lowercase
  4. L = []
  5. for i in range(n):
  6. s = "-".join(alpha[i:n])
  7. L.append((s[::-1]+s[1:]).center(4*n-3, "-"))
  8. print('\n'.join(L[:0:-1]+L))
  9. if __name__ == '__main__':
  10. n = int(input())
  11. print_rangoli(n)
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube