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.
def print_rangoli(size):
# your code goes here
for x in range (96+size,96,-1):
listcharsl = [chr(c) for c in range (96+size,x-1, -1)]
listcharsr = [chr(c) for c in range (x+1,97+size)]
print ("--"(x-97),"-".join(listcharsl), "-" if listcharsr else "", "-".join(listcharsr),"--"(x-97), sep="")
for x in range (1,size):
listcharsl.pop()
listcharsr.pop(0)
print ("--"*(x),"-".join(listcharsl), "-" if listcharsr else "", "-".join(listcharsr),"--"*(x), sep="")
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 →
def print_rangoli(size): # your code goes here for x in range (96+size,96,-1): listcharsl = [chr(c) for c in range (96+size,x-1, -1)] listcharsr = [chr(c) for c in range (x+1,97+size)] print ("--"(x-97),"-".join(listcharsl), "-" if listcharsr else "", "-".join(listcharsr),"--"(x-97), sep="")