0
3

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 1 year has passed since last update.

pythonの2重配列の四角かっこ[]を外す方法

Posted at

「.joinを使う」、「*argsを使う」などあるが、全然うまくいかないので別の方法を。

hogelist = [['0'], ['1'], ['0'], ['1'], ['0']]

//iではなく[i]を指定することで、中身だけを取り出す。
for [i] in hogelist:
            //文字の置き換え(リプレイス)もできる
            # i = str(i).replace('0', ' ')
            # i = str(i).replace('1', '*')
            print(str(i), end='')
        # end=''の影響で改行が続くのを防ぐための空のprint文
        print("")

出力結果

01010

0
3
4

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
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?