# Why I get 1-element Vector{Sym} instead of just number as answer from SymPy?

**URL:** <https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946>\
**Category:** General Usage\
**Tags:** package\
**Created:** [February 21, 2023, 5:56am UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946 "2023-02-21T05:56:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [February 21, 2023, 5:56am UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946/1 "2023-02-21T05:56:31Z")

</div>

Hi all,

it is just a curious question. I am calculating `k` from this

\int\_{0}^{180} kx^{2} (180 - x) dx = 1

solving for k I should obtain \frac{1}{87,480,000} but why the answer contains 1-element Vector? instead of just the number?

```julia
using SymPy
@syms x, k

a,b = 0, 180
k1 = solve(integrate(k*(x^2)*(180-x),(x,a,b)) ~ 1, k)

```

```julia
1-element Vector{Sym}:
 1/87480000

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 21, 2023, 5:57am UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946/2 "2023-02-21T05:57:55Z")

</div>

that’s just how the interface works. My guess is to make type stable – i.e. you don’t get `Sym` vs. `Vector{Sym}` depending on how many variables you have, which is a runtime property

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [February 21, 2023, 12:51pm UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946/3 "2023-02-21T12:51:48Z")

</div>

There is this problem I try:

```julia
k1::Vector

```

1-element Vector{Sym}:  
95802719.0924019

```julia
k1::Int64

```

TypeError: in typeassert, expected Int64, got a value of type Vector{Sym}  
Stacktrace:

I want to turn `k1` into integer or float… how?

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [February 21, 2023, 12:56pm UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946/4 "2023-02-21T12:56:04Z")

</div>

I got it when I type

```julia
k1[1]

```

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [February 21, 2023, 3:25pm UTC](https://discourse.julialang.org/t/why-i-get-1-element-vector-sym-instead-of-just-number-as-answer-from-sympy/94946/5 "2023-02-21T15:25:18Z")

</div>

I’m a big fan of `only(k1)` in this situation. It’s the same thing as `k1[1]` except it will throw an error if `length(k1) != 1`.
