Hello
I'm new to python programming. In the code below, I think the if statement is strange.
import numpy as np
n_zero=int(input('Insert the amount of 0: '))
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: '))
data = [0]*n_zero + [1]*n_one + [2]*n_two + [3]*n_three
if data==2n-1:
np.random.shuffle(data)
datastring = ''.join(map(str, data))
files = open('decode.txt', 'w')
files.write(datastring)
files.close()
print ("Data string is : %s " % datastring )
else:
print (error)
What I want to do is calculate the length of the data and print out an array of 2n-1 length. Thank you.
Recommended Posts