P
P
phawer-72020-08-05 13:32:44
Python
phawer-7, 2020-08-05 13:32:44

I don't understand simple Python code, can you help me?

def total(a=5, *numbers, **phonebook):
    print('a', a)
    for single_time in numbers:
        print('single_time', single_time)
    for first_part, second_part in phonebook.items():
        print(first_part, second_part)

print(total(10,1,2,3, Jack=1123, John=2231, Inge=1560))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-08-05
@phawer-7

You created a function that takes a variable number of parameters:
1 - "a"
2 - a list of numbers (1,2,3)
3 - a dictionary {Jack=1123, John=2231, Inge=1560}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question