# ValueError: setting an array element with a sequence

**URL:** <https://discuss.python.org/t/valueerror-setting-an-array-element-with-a-sequence/55288>\
**Category:** Python Help\
**Created:** [June 9, 2024, 8:57am UTC](https://discuss.python.org/t/valueerror-setting-an-array-element-with-a-sequence/55288 "2024-06-09T08:57:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [June 9, 2024, 5:53pm UTC](https://discuss.python.org/t/valueerror-setting-an-array-element-with-a-sequence/55288/4 "2024-06-09T17:53:02Z")

</div>

Here is an example of what generates the stated exception. When you define an array, it should be `X x Y` dimensions. For example, with X = 3, and Y = 5, you will have a 3 x 5 dimensional array. If you don’t have a value for a given cell, you have to assign it a value of `0` and NOT leave it blank.

Here is a visual that may help in understanding this concept a little bit better:

![ValueError_Exception](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/e/b/eb24807262f0e0adf5a53e63a38093ef3cef6cc0.png)

In figure `(a)` the the first row has three columns. The second row has two columns. It needs to have three columns. However, the value has to be set to `0` if it has no value. It cannot be left blank. Otherwise, a `ValueError: setting an array element with a sequence` exception will be generated. Refer to figure `(b)` for the correct way of defining an array.

Therefore, somewhere in your script, an array or an array like object is being defined as per the characteristics of figure `(a)`.

---

_[View the full topic](https://discuss.python.org/t/valueerror-setting-an-array-element-with-a-sequence/55288)._
