文字列を複数の変数に格納する。
入力
a b
サンプルコード:sample_48.py
x, y = input().split()
print(x)
print(y)
実行結果
a
b
文字列をリストに格納する。
入力
a b c d e
サンプルコード:sample_49.py
x = list(input().split())
print(x)
実行結果
['a', 'b', 'c', 'd', 'e']
入力
a b c d e
サンプルコード:sample_50.py
x = [i for i in input().split()]
print(x)
実行結果
['a', 'b', 'c', 'd', 'e']