1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[python] if文の正しい使い方

Last updated at Posted at 2017-01-25

こんにちは

pythonのプログラミングの初めての者です。
以下のコードで、確かif文のところがおかしと思います。

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)

やりたいことはdataの長さを計算して、2n-1の長さの配列をプリントアウトしたいです。
よろしくお願いします.

1
0
7

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?