# Course 5 W1 Assignment 2 Exercise 4

**URL:** <https://community.deeplearning.ai/t/course-5-w1-assignment-2-exercise-4/22820>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [July 23, 2021, 11:15am UTC](https://community.deeplearning.ai/t/course-5-w1-assignment-2-exercise-4/22820 "2021-07-23T11:15:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karnikkanojia](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@karnikkanojia](https://community.deeplearning.ai/u/karnikkanojia)\
**Post date:** [July 23, 2021, 11:15am UTC](https://community.deeplearning.ai/t/course-5-w1-assignment-2-exercise-4/22820/1 "2021-07-23T11:15:13Z")

</div>

I’m trying to write the model() function for exercise 4.  
I’m encountering this error. But i cannot understand why this seems to be happening. Here is the error:

```auto
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-725c093d6b91> in <module>
----> 1 parameters, last_name = model(data.split("\n"), ix_to_char, char_to_ix, 22001, verbose = True)
      2 
      3 assert last_name == 'Trodonosaurus\n', "Wrong expected output"
      4 print("\033[92mAll tests passed!")

<ipython-input-20-c02a61e9c4b1> in model(data_x, ix_to_char, char_to_ix, num_iterations, n_a, dino_names, vocab_size, verbose)
     86 
     87 # Sample indices and print them
---> 88 sampled_indices = sample(parameters, char_to_ix, seed)
     89 last_dino_name = get_sample(sampled_indices, ix_to_char)
     90 print(last_dino_name.replace('\n', ''))

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

```

Though the sample function i created before does accept 3 positional arguments.  
The head of the sample() is:

```python
def sample(parameters, char_to_ix, seed):

```

The test of sample function does gets passed. Still im encountering such error.  
I’m sorry i can’t post the code of the sample function.

---

<div class="post-metadata">

**Author:** ![Mubsi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/mubsi/32/94983_2.png) [@Mubsi](https://community.deeplearning.ai/u/Mubsi)\
**Post date:** [July 23, 2021, 5:46pm UTC](https://community.deeplearning.ai/t/course-5-w1-assignment-2-exercise-4/22820/2 "2021-07-23T17:46:11Z")

</div>

Hi @karnikkanojia , please be mindful about posting your queries in the right category. You are posting your query in the [General Discussions](https://community.deeplearning.ai/c/random-discussions/23) category. This category is not monitored by our mentors. Your specific query belongs to, I’m guessing, [DLS Course 5](https://community.deeplearning.ai/c/deep-learning-specialization/dls-course-5/16).

If you are unclear about how to use Discourse, we have made this [guide](https://docs.google.com/document/d/1xrWj9plgme08hcxj5L5tEhOuQCa4W8_eN3E1kSb2pW0/edit) for our learners. Hopefully reading it will help you out in posting in the appropriate categories next time.

For now, I have moved your post in the DLS Course 5 category. For future, in order to get swift responses, post in the appropriate categories.

Thank you and happy learning!  
Mubsi

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 24, 2021, 2:27am UTC](https://community.deeplearning.ai/t/course-5-w1-assignment-2-exercise-4/22820/4 "2021-07-24T02:27:35Z")

</div>

Regarding your error message.

In the model() function, perhaps the values in the ‘parameters’ or ‘char\_to\_ix’ variables are incorrect.  
Did your code modify either of these variables?
