I have written this code to generate random numbers. The code work as expected but I am trying to store the value in a variable using list comprehension. Any help in rearranging the code to fit in one list comprehension. Reason why I want to in list compr because it is faster considering the large range of list.
import numpy as np
import random
a = np.arange(10)
n = .8
train_len = int(len(a) * n)
rand_train = [ i for i in range(len(a))]
for _ in range(1):
print(random.sample(rand_train, k=train_len))