Hello

I'm just studying python. For now, I'm writing programming to create an array of random numbers. Random numbers are coming out, but I couldn't get the shape I wanted. The code I wrote is as follows.

import numpy as np

n_zero=input('Insert the amount of 0: ') n_one =input('Insert the amount of 1: ') n_two =input('Insert the amount of 2: ') n_three = input('Insert the amount of 3: ')

data = [0]*n_zero + [1]*n_one + [2]*n_two + [3]*n_three np.random.shuffle(data) print(data)

The output result is

Insert the amount of 0: 6 Insert the amount of 1: 2 Insert the amount of 2: 1 Insert the amount of 3: 2 [3, 0, 0, 0, 1, 0, 1, 0, 3, 0, 2]

The result you want is like this. 30001010302

The comma and unbracketed form is the desired result.

Thank you.

Recommended Posts