Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created February 22, 2017 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/afc68ac34d7db66f39071f71e05eb4aa to your computer and use it in GitHub Desktop.
Save chuck0523/afc68ac34d7db66f39071f71e05eb4aa to your computer and use it in GitHub Desktop.
# 1行の入力データを分割
data = input().split() # "1 2 3"と入力
print(data) #['1', '2', '3']
print(data[0]) # 1
print(type(data[0])) # str
# 入力データの数値化
nums = list(map(int, input().split())) # "1 2 3"と入力
## Python3では、listを使う必要がある。mapはリストを返す仕様ではなくなったため。
print(nums) # [1, 2, 3]
print(nums[0]) # 1
print(type(nums[0])) # int
# 浮動小数点数
floats = list(map(float, input().split()))
# リストではなく、別個の変数に代入する場合。
a, b, c = input().split()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment