0

I have some strings that I'm printing out and I want to align them in order to make them appear neat.

colours = ["Red", "Green", "Yellow"]
quantities = {"Red" : 6, "Green" : 4,  "Yellow" : 9

Here is how I am currently printing them out:

for colour in colours:
  print("{}: {}".format(colours[colour], quantities[colour]))

However they come out looking like this:

Red: 6
Green: 4
Yellow: 9

When I would like them to come out like:

Red:      6
Green:    4
Yellow:   9
vaultah
  • 44,105
  • 12
  • 114
  • 143

1 Answers1

1

(Correcting some error in you code)... You can use \t to insert tab

for colour in colours:
  print("{}:\t {}".format(colour, quantities[colour]))
Aguy
  • 7,851
  • 5
  • 31
  • 58