[python] Correct usage of if statement

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

[python] Correct usage of if statement
[Python] Correct usage of map
[Python] Correct usage of join
Python if statement
[Python] if statement
Usage of Python locals ()
Python basic if statement
[Python] Basic pattern and usage of if statement (comparison operator and Boolean operator)
Addition with Python if statement
Sample usage of Python pickle
Basic usage of Python f-string
[Python] File operation using if statement
[Introduction to Udemy Python3 + Application] 33. if statement
Non-logical operator usage of or in python
Introduction of Python
Unfamiliar if statement
Basics of python ①
Copy of python
Python exec statement
Python assert statement
Introduction of Python
Python hand play (one line notation of if)
[Python] Class type and usage of datetime module
[Introduction to Python] Basic usage of lambda expressions
[Python] Operation of enumerate
List of python modules
Python basics ② for statement
Unification of Python environment
Copy of python preferences
Basics of Python scraping basics
Summary of pyenv usage
Basic usage of flask-classy
[python] behavior of argmax
Python --Explanation and usage summary of the top 24 packages
the zen of Python
python decorator usage notes
Basic usage of SQLAlchemy
Installation of Python 3.3 rc1
[Python] pytest-mock Usage notes
# 4 [python] Basics of functions
Basic knowledge of Python
Sober trivia of python3
Summary of Python arguments
A Java programmer studied Python. (for, if, while statement)
[Introduction to Python] Basic usage of the library matplotlib
Basics of python: Output
Installation of matplotlib (Python 3.3.2)
Application of Python 3 vars
Various processing of Python
[Python] for statement error
Why do you add a main ()-if statement in Python?
Using multiple versions of Python on Mac OS X (2) Usage
Construction of Python local development environment Part 2 (pyenv-virtualenv, pip usage)
[Python] How to write an if statement in one sentence.
[Road to intermediate Python] Use if statement in list comprehension
Turn an array of strings with a for statement (Python3)
[2020/06 latest version] Basic usage of python dependency management tool poetry
Super basic usage of pytest
Python list, for statement, dictionary
Summary of python file operations
Summary of Python3 list operations