3
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 5 years have passed since last update.

Python3 文字列を一文字ずつ分割

Last updated at Posted at 2019-04-18

list を用いる

例:"Hello"を一文字ずつ分割したいとき

word = list("Hello")
print(word)
>>>
['H', 'e', 'l', 'l', 'o']

標準入力から取得する場合

入力
HEllo
word = list(input())
print(word)
>>>
['H', 'e', 'l', 'l', 'o']

4月19日追記

@shiracamus さんより分割代入による方法を教えていただきました。
※コメント欄参照

3
1
2

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