Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Placeholders
Numbers
Date and time
Padding and Alignment
13. String placeholders aligned
Summary

Instruction

Good job! In the previous exercise, you could see that values were aligned to the left, which is the default behavior. We can change alignments using < (explicitly align to the left), ^ (align to the center), and > (align to the right). Take a look:

user_name = 'Kate'
greeting = 'Hello {:^10s}!'.format(user_name)
print(greeting)

Result:

Hello    Kate   !

Exercise

Given a dictionary of menu items, create a visually appealing menu:

           --MENU--           
Each starter             25.00
Each main course         60.00
Each dessert             35.00
Soft drink:              15.00
  1. The --MENU-- string should take up 30 characters and be centered.
  2. Menu items should take up 25 characters.
  3. Prices should take up 5 characters, including 2 digits after the decimal point.

Stuck? Here's a hint!

Use the following for loop:

for key, value in menu.items():