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/3b54862ef4079ba91b532913fd153876 to your computer and use it in GitHub Desktop.
Save chuck0523/3b54862ef4079ba91b532913fd153876 to your computer and use it in GitHub Desktop.
## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
a.append(input()) # 3度の入力に対して、1, 2, 3 と入力。
print(a) # ['1', '2', '3']
## 内包表記だとベター
N = int(input())
a = [input() for i in range(N)]
print(a)
# 終了条件あり
# -1が入力されるまでデータ入力が続く、みたいなパターン。
a = []
while True:
num = input()
if num == -1: # TODO: ここエラーになる。修正する。
break
a.append(input())
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment