[PYTHON] Output conditions

Hello

I'm just starting to learn python. I am writing the code below to output a random number with length s including 0,1,2,3.

import numpy as np

n_one =int(input('Insert the amount of 1: '))
n_two =int(input('Insert the amount of 2: '))
n_three = int(input('Insert the amount of 3: '))
l = n_one+n_two+n_three
n_zero = l+1
s = (2*(n_zero))-1


data = [0]*n_zero + [1]*n_one + [2]*n_two + [3]*n_three
print ("Data string length is %d"  % len(data))

while data[0] == 0 and data[s-1]!=0:
         np.random.shuffle(data)
datastring = ''.join(map(str, data))
datastring = str(int(datastring))
files = open('decode.txt', 'w')
files.write(datastring)
files.write('\n')
files.close()
print("Data string is : %s " % datastring)

The problem is the output. I want the output to start with a non-zero number and end with 0. For now, using while minutes, sometimes it doesn't work very well. If you have any suggestions, thank you.

Recommended Posts

Output conditions
Output beginner
shapely svg output
python learning output