You are viewing a single comment's thread. Return to all comments →
Try this:
def print_formatted(number): width = len(bin(number)[2:]) nList = [[i, oct(i)[2:], hex(i)[2:], bin(i)[2:]] for i in range(1, number+1)] nList = [map(lambda x:str(x).rjust(width).upper(), item) for item in nList] nList = [' '.join(item) for item in nList] nList = '\n'.join(nList) print(nList)
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
String Formatting
You are viewing a single comment's thread. Return to all comments →
Try this: