Kickstart 2020 with new opportunities! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Placeholders
Numbers
Date and time
14. String placeholders extended
Summary

Instruction

Perfect! When we use <, ^, or >, we can also specify an optional character that will be used for padding instead of white spaces:

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

Result:

Hello ___Kate___!

The optional character is placed before the <, ^, or > sign.

Exercise

Modify the menu from the previous exercise so that it looks as follows:

_____________MENU_____________
Each starter.............25.00
Each main course.........60.00
Each dessert.............35.00
Soft drink:..............15.00

Stuck? Here's a hint!

Use underscores (_) and dots (.) to change the appearance of the menu.