'Generate numpy.arrange from a list

I have the following list list_a=[4.0, 8.0, 0.5] and i need to get numpy.arange(4.0, 8.0, 0.5)

Issue is i tried to strip the square brackets from my list and place into the numpy.arrange() but it copied as a string

import numpy

list_a=[4.0, 8.0, 0.5]
list_a_strip=str(list_a)[1:-1]

print(f"numpy_arange: {numpy.arange(list_a_strip)}")

Error is TypeError: unsupported operand type(s) for -: 'str' and 'int'

But when i manually put the values in, all looks good

import numpy

list_a=[4.0, 8.0, 0.5]
list_a_strip=str(list_a)[1:-1]
​
print(f"numpy_arange: {numpy.arange(4.0, 8.0, 0.5)}")
numpy_arange: [4.  4.5 5.  5.5 6.  6.5 7.  7.5]

So how i can generate the numpy.arange() from a list?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source