0
1

More than 3 years have passed since last update.

pythonで文字列を1文字ずつのリスト形式に変換する

Last updated at Posted at 2020-05-07

文字列の場合

#やりたいこと
#'hello' ⇒ ['h','e','l','l','o']

a = 'hello'
print(list(a))

実行結果は以下のようになる

['h', 'e', 'l', 'l', 'o']

数値の場合

b = 123456789
print(list(str(b)))

実行結果は以下のようになる

['1', '2', '3', '4', '5', '6', '7', '8', '9']
0
1
0

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