Python Input Note in AtCoder

introduction It is a memorandum of standard input. This one is better! Please let me know if you have any.

Inputs

line: 1 line

input: Only one (str / int)

input.py


S = input()
N = int(input())

console


string
9999

input: 2 or more (str / int)

input.py


S1, S2 = input().split()
S = input().split()
N1, N2 = map(int, input().split())
N = list(map(int, input().split())
Sunny Rainy
Sunny Rainy Cloudy => ["Sunny", "Rainy", "Cloudy"]
9999 8888
7777 6666 5555 => [7777, 6666, 5555]

line: 2 or more lines

input: Multiple line feed input (str / int)

input.py


N = int(input())
S = [input() for _ in range(N)]
N = [int(input()) for _ in range(N)]
3 ... N(Number of lines)
aa
bc
io => ["aa", "bc", "io"]
3
2
9 => [3, 2, 9]

input: matrix

input.py


N = int(input())
S = [input().split() for _ in range(N)]
3
aa bc 82 00 2w
oe jj ed 2s pw
12 de co 99 jd 
 => [['aa', 'bc', '82', '00', '2w'], ['oe', 'jj', 'ed', '2s', 'pw'], ['12', 'de', 'co', '99', 'jd']]

input: Line feed system multiple numerical input out: 2D array

input.py


N = int(input())
S = [[int(i) for i in input().strip()] for _ in range(N)]
3
123456
789012
345678
 => [[1, 2, 3, 4, 5, 6], [7, 8, 9, 0, 1, 2], [3, 4, 5, 6, 7, 8]]

Recommended Posts

Python Input Note in AtCoder
Daily AtCoder # 36 in Python
Daily AtCoder # 2 in Python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Daily AtCoder # 53 in Python
Key input in Python
Daily AtCoder # 33 in Python
Daily AtCoder # 7 in Python
Daily AtCoder # 24 in Python
Daily AtCoder # 37 in Python
Daily AtCoder # 8 in Python
Daily AtCoder # 42 in Python
Daily AtCoder # 21 in Python
Daily AtCoder # 17 in Python
Daily AtCoder # 38 in Python
Daily AtCoder # 54 in Python
Daily AtCoder # 15 in Python
Daily AtCoder # 47 in Python
Daily AtCoder # 13 in Python
Daily AtCoder # 45 in Python
Daily AtCoder # 30 in Python
Daily AtCoder # 40 in Python
Daily AtCoder # 10 in Python
Daily AtCoder # 5 in Python
Daily AtCoder # 28 in Python
Daily AtCoder # 39 in Python
Daily AtCoder # 20 in Python
Daily AtCoder # 19 in Python
Daily AtCoder # 52 in Python
Daily AtCoder # 3 in Python
Daily AtCoder # 14 in Python
Daily AtCoder # 50 in Python
Daily AtCoder # 26 in Python
Daily AtCoder # 4 in Python
Daily AtCoder # 43 in Python
Daily AtCoder # 29 in Python
Daily AtCoder # 22 in Python
Daily AtCoder # 49 in Python
Daily AtCoder # 27 in Python
Daily AtCoder # 1 in Python
Daily AtCoder # 25 in Python
Daily AtCoder # 16 in Python
Daily AtCoder # 12 in Python
Daily AtCoder # 48 in Python
Daily AtCoder # 23 in Python
Daily AtCoder # 34 in Python
Daily AtCoder # 51 in Python
Key input in Python
Daily AtCoder # 31 in Python
Daily AtCoder # 46 in Python
Daily AtCoder # 35 in Python
Daily AtCoder # 9 in Python
Daily AtCoder # 44 in Python
Daily AtCoder # 41 in Python
Atcoder ABC164 A-C in Python
Atcoder ABC167 A-D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
[AtCoder] ABC165C Personal Note [Python]