1
tup_list = [1,2,3,4,5]
weight_list = [0.5,0.6,0.1,0.7]   
draw = choice(tup_list, sample_size_d, replace=False, weight_list)

when I try to run it, I get error: SyntaxError: non-keyword arg after keyword arg How could I fix it?

cai
  • 99
  • 1
  • 5
  • 2
    Possible duplicate of [Python: SyntaxError: non-keyword after keyword arg](http://stackoverflow.com/questions/14247732/python-syntaxerror-non-keyword-after-keyword-arg) – Diogo Rocha Apr 24 '16 at 18:29

1 Answers1

0

Here weight_list is a non-keyword arg. When calling a function in Python, all keyword arguments (key=value type) should follow all non-keyword arguments. Your call to choice should be like:

draw = choice(tup_list, sample_size_d, weight_list, replace=False)

See this question: Python normal arguments vs. keyword arguments

Community
  • 1
  • 1
trans1st0r
  • 2,023
  • 2
  • 17
  • 23