+ 2
How to align string statements
school excersise asks us to print off total amounts, but I'm trying to align all totals underneath eachother. anyone's help is appreciated
3 Respuestas
+ 6
you can use format.
+ 6
Thanks for attaching Python documentation. I haven't done formatting in 4 months so I am rusty
+ 5
Using the format function for strings ...
lower = [70, 79, 88, 97, 106]
upper = [78, 87, 105, 114, 123]
num = [5, 3, 4, 2, 6, 4]
for l, u, n in zip(lower, upper, num):
print('{0:>8} {1}'.format('{0}-{1}:'.format(l, u), '*' * n))
https://docs.python.org/3/library/string.html#format-specification-mini-language