Chapter 32

   1.3.2.2 文字列

小栁 斉
小栁 斉
2023.08.27に更新

文字列を複数の変数に格納する。

入力
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']