C5W1 A2 Ex4:sample() takes from 1 to 2 positional arguments but 3 were given

there is some error about the sample function, in ex 4,
but the sample function is correct.
(here is the feedback from grader:Code Cell UNQ_C2: Function ‘sample’ is correct.)
and the 3 arguments of sample function is correctly defined in the ex 4 code

88                 # Sample indices and print them
---> 89                 sampled_indices = sample(parameters, char_to_ix, seed)
     90                 last_dino_name = get_sample(sampled_indices, ix_to_char)
     91                 print(last_dino_name.replace('\n', ''))

**TypeError: sample() takes from 1 to 2 positional arguments but 3 were given**

Try restarting the kernel and run all the cells again.

“sample” is a pretty common function name, and it’s possible the kernel is pickup up a “sample()” function from some other default package.

1 Like