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 here# we start from the middle line to the end (== second half)lines=list()forbinrange(size):base=chr(ord("a")+b)temp=list()foriinrange(size-b):temp.append(chr(ord(base)+i))chars_to_build_line=temp[:0:-1]chars_to_build_line.extend(temp)line="-".join(chars_to_build_line)lines.append(line)result=lines[:0:-1]result.extend(lines)width=max(map(len,result))forlinresult:print("{text:-^{w}}".format(text=l, w=width))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alphabet Rangoli
You are viewing a single comment's thread. Return to all comments →