0
0

More than 1 year has passed since last update.

Pythonで1行で複数データを扱う方法

Posted at

Python3で1行でスペースで分けられた複数の数の和を求めるプログラムです。

# coding: utf-8
# 入力
input_line = input()
#数の和の変数を定義
goukei=0
#スペースで仕切って数字を取り出す
for num in input_line.split():
#データを整数型に変換して合計を求める
    goukei += int(num)
#合計を標準出力する
print(goukei)
0
0
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
0
0