Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,038 questions

40,794 answers

573 users

How to create a function with arbitrary number of keyword parameters in Python

3 Answers

0 votes
def function(**keywords_args):
    print(keywords_args)


function(p="python", j="java", c="c#")


'''
run:

{'c': 'c#', 'p': 'python', 'j': 'java'}

'''

 





answered Dec 16, 2017 by avibootz
0 votes
def function(**keywords_args):
    for k in keywords_args:
        print(k)


function(pp="python", jj="java", cc="c#")


'''
run:

cc
pp
jj

'''

 





answered Dec 16, 2017 by avibootz
0 votes
def function(**keywords_args):
    for k in keywords_args:
        print(keywords_args[k])


function(pp="python", jj="java", cc="c#", dd="php")


'''
run:

java
c#
python
php

'''

 





answered Dec 16, 2017 by avibootz
edited Dec 17, 2017 by avibootz
...