Skip to content

Instantly share code, notes, and snippets.

@pelid
Last active December 4, 2018 11:16
Show Gist options
  • Save pelid/dcd98c469cb2f653f37015afa208f7e4 to your computer and use it in GitHub Desktop.
Save pelid/dcd98c469cb2f653f37015afa208f7e4 to your computer and use it in GitHub Desktop.
Template for print_receipt.py
def create_formatted_receipt(products):
"""Функция создает новый чек, принимает на вход любой список покупок - `products`.
Функция сама не вызывает `print`, только готовит строки к последующему
выводу на экран или печати."""
receipt_lines = []
# поместите сюда основной цикл, наполните receipt_lines строками.
# используйте метод списка append - receipt_lines.append(line)
return receipt_lines
def print_all_lines(lines):
for line in lines:
print(line)
receipt = create_formatted_receipt(PRODUCTS)
print_all_lines(receipt)
@pelid
Copy link
Author

pelid commented Dec 4, 2018

В функции def create_formatted_receipt используется механизм встроенной документации docstings. Это строка с тройными двойными кавычками """ .... """, размещенная сразу под объявлением функции.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment