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.
- Prepare
- Python
- Strings
- String Formatting
- Discussions
String Formatting
String Formatting
Sort by
recency
|
1699 Discussions
|
Please Login in order to post a comment
My Code:
def print_formatted(number):
if name == 'main': n = int(input()) print_formatted(n)
Try this:
Use the format function in python 3.
I think it would be better to encapsulate it as a function
a=[] for i in range(1,number+1): b="" d=format(i, 'X') e=format(i,"o") f=format(i,'b') g=format(number,'b') b=" "(len(f"{number}")-len(f"{i}"))+f" {i}"+" "(len(g)-(len(e)-1))+f"{e}"+" "(len(g)-(len(d)-1))+f"{d}"+" "(len(g)-(len(f)-1))+f"{f}" a.append(b)