Kodewick
Start learning →
Starter←→0 / 80

Shelf labels

#021StarterStrings3 min

The second-hand bookshop is making shelf labels. Some titles are all capitals, some have extra spaces at the ends. Write shelf_label(book): remove the spaces at both ends, then make each word start with a capital and the rest lower case. An empty string gives an empty string.

Examples
shelf_label(" the little prince ")→'The Little Prince'
shelf_label("MOBY DICK")→'Moby Dick'
main.py
def shelf_label(book):
    # your code here: strip() then title(), and return the result
    return book
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.