Created
March 10, 2022 05:50
-
-
Save neilkuan/45944d94ccf394ff894d2ee70cc92f26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def buy_list(items: dict[str, int]): | |
lists = [] | |
for i in items.keys(): | |
lists.append(f'{i}: {items.get(i)}') | |
return '\n'.join(lists) | |
def note(note_name, date, **items): | |
print(f''' | |
{note_name} | |
Date: {date} | |
Author: myself | |
{buy_list(items)}''') | |
items={'cola':31, 'cake':62} | |
note(note_name='7-11 buy list', date='2022/03/11', cola=30, cake=60) | |
note(note_name='7-11 buy list', date='2022/03/11', **items) | |
# example output... | |
# 7-11 buy list | |
# Date: 2022/03/11 | |
# Author: myself | |
# cola: 30 | |
# cake: 60 | |
# 7-11 buy list | |
# Date: 2022/03/11 | |
# Author: myself | |
# cola: 31 | |
# cake: 62 | |
def func(arg1, arg2, *args, **kwargs): | |
print(arg1) | |
print(arg2) | |
print(args) | |
print(kwargs) | |
func(1,2,3, a=4) | |
# example output... | |
# 1 | |
# 2 | |
# (3,) | |
# {'a': 4} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment