You are viewing a single comment's thread. Return to all comments →
Use the format function in python 3.
w = len(format(number, 'b')) for i in range(1, number+1): dec = str(i).rjust(w) octal = format(i, 'o').rjust(w) hexa = format(i, 'X').rjust(w) binary = format(i, 'b').rjust(w) print(f"{dec} {octal} {hexa} {binary}")
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 →
Use the format function in python 3.