practicing python#
def my_function(*args, **kwargs):
print(args)
print(*args)
print(kwargs)
print(kwargs.keys())
print(*kwargs)
#print([key for key in *kwargs])
pass
my_function(1, b=3, c=4)
(1,)
1
{'b': 3, 'c': 4}
dict_keys(['b', 'c'])
b c
# Format each element of the list with two decimal places and join them into a single string
def formatted_list(my_list,brackets=True):
if brackets:
f_list = '['
else:
f_list = ''
for item in my_list:
f_list = f_list+f' {item:.2f}'
if brackets:
f_list = f_list + ' ]'
return f_list
formatted_list([44.444, 7.7777, 99.999])
'[ 44.44 7.78 100.00 ]'