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 さんより分割代入による方法を教えていただきました。
※コメント欄参照
Go to list of users who liked
More than 5 years have passed since last update.
例:"Hello"を一文字ずつ分割したいとき
word = list("Hello")
print(word)
>>>
['H', 'e', 'l', 'l', 'o']
標準入力から取得する場合
HEllo
word = list(input())
print(word)
>>>
['H', 'e', 'l', 'l', 'o']
@shiracamus さんより分割代入による方法を教えていただきました。
※コメント欄参照
Register as a new user and use Qiita more conveniently
Go to list of users who liked