We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defprint_rangoli(size):# your code goes herea=ord('a')alphabet=[chr(a+i)foriinrange(size)]length_center=(((size*2)-1)*2)-1rangoli=""foriinrange(size-1,-1,-1):right_side=alphabet[i:]left_side=right_side[::-1][:-1]line=left_side+right_siderangoli+=f'{"-".join(line).center(length_center,"-")}\n'foriinrange(1,size):right_side=alphabet[i:]left_side=right_side[::-1][:-1]line=left_side+right_siderangoli+=f'{"-".join(line).center(length_center,"-")}\n'print(rangoli)if__name__=='__main__':n=int(input())print_rangoli(n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Alphabet Rangoli
You are viewing a single comment's thread. Return to all comments →