Created
February 22, 2017 01:31
-
-
Save chuck0523/3b54862ef4079ba91b532913fd153876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン | |
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