0
1

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.

文字列とリストの変換

Last updated at Posted at 2022-11-11

文字列を一文字ずつにリスト化する方法、及び、一文字ずつのリストを文字列に統合する方法を知らなかったので書きました。

文字列を一文字ずつのリストにする

# 「あいうえお」をリストにする
mojiretsu = 'あいうえお'
mojilist = list(mojiretsu)

一文字ずつのリストを文字列に統合する

mojiretsu = ''.join(mojilist)

参考文献

@cress_cc. "文字列を1文字ずつのリストにする". Qiita. 2019/05/09. https://qiita.com/cress_cc/items/5600be0416a0be72ecfb, (2022/11/11).

ひろ. "Pythonのリストと文字列を相互に変換する方法まとめ". HEADBOOST. 2021/05/06. https://www.headboost.jp/python-strings-into-a-list/#index_id0, (2022/11/11).

0
1
1

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?