T
T
Timofey Shestakov2020-06-20 13:00:42
Python
Timofey Shestakov, 2020-06-20 13:00:42

How to create an array where the number of elements in a row is equal to the row number?

How to create an array in Python where the number of elements in a string will be equal to the number of the string itself? The elements themselves are random from 1 to 99.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-06-20
@LazyTalent

>>> import numpy as np
>>> 
>>> foo = 'blah blah'
>>> arr = np.random.randint(1, 99, len(foo))
>>> arr
array([40, 65, 39, 91, 55, 39, 38, 54, 48])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question