LoginSignup
2
2

More than 5 years have passed since last update.

ユーザー入力input().split()で可変個数の変数を受け取る

Posted at

変数a, bに以下のような入力が必要な場合

insert 4   #変数が2つ
deleteFirst  #変数が1つ

a, *b = input().split()
insert 4
print(a, b)
insert ['4']

a, *b = input().split()
deleteFirst
print(a, b)
deleteFirst []

2
2
0

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
2
2