[Python] About standard input

Describe what you have learned about acquiring standard input

Enter N lines

【input】
afd
agdp
hj

【output】
afd
agdp
hj

for a in range(3):
    c = input()
    print(c)

Input of two integers separated by a single-byte space

【input】
6 90
【output】
6
90

input_line = input().split()

for a in input_line:
    print(a)

Input of N integers given in the second line


【input】
6
56 78 39 26 4 553

【output】
56 
78 
39 
26 
4 
553

【syntax】
input_line = int(input())
#Get the first of the inputs

try:
    for a in range(input_line):
        v = input().split()
except EOFError:
    pass
#1. 1. The first numerical value obtained in the for statement is rotated by range and assigned to the variable a in order from 0.
#2. Get the second input on the second line of for minutes and split()Split the string with
#3. Repeat for the first number obtained

for d in v:
    print(d)

※try-If you do not include an except statement, EOFError:I get the error EOF when reading a line

Input of two sets of integers

【input】
4
57 10
53 38
9  46
96 29

【output】
57 10
53 38
9  46
96 29

【syntax】
input_line = int(input())

for i in range(input_line):
    a, b = input().split()
#Here a,The values on the first and second lines are separated in b.
    print(a, b)

Selection from a set of integers (extraction from a specific number of sets)

【input】
10
46 5
2 7
89 6
81 0
46 675
2 948
68 35
17 10
26 64
28 95

【output】
26 64

【syntax】
#Output with if statement
input_line = int(input())

for a in range(input_line):
    x, y = input().split()
    if a == 7: 
        print(x, y)


[Another solution]
#Add to list and output
myinput = []
input_line = int(input())

for a in range(input_line):
    x, y = input().split()
    myinput.append((x, y))

print(' '.join(myinput[7]))

It has nothing to do with input

import string
#The string module is a module that gets a string

alphabets = string.ascii_uppercase
# ABCDEFGHIJKLMNOPQRSTUVWXYZ
# ascii_lowercase gets a to z
# ascii_uppercase gets A to Z
#digits get the numbers

#What number in the index is X?
print(alphabets.index("X") + 1)  # 24

Updated from time to time

Recommended Posts

[Python] About standard input
[Python3] Standard input [Cheat sheet]
Python3 standard input (competition pro)
Standard input / summary / python, ruby
Receiving standard input tips @ python
Python3 standard input for competitive programming
About python slices
About python comprehension
About Python tqdm.
About python yield
About python, class
About python inheritance
About python, range ()
About python decorators
Standard input summary
About python reference
About Python decorators
[Python] About multi-process
Python Paiza-Various skill checks and standard input
Python3 standard input I tried to summarize
Atcoder standard input set for beginners (python)
[Python] Add comments to standard input files
About Python for loops
Summary about Python scraping
About function arguments (python)
Key input in Python
[Python] Memo about functions
Summary about Python3 + OpenCV3
About Python3 character code
About Python development environment
Python: About function arguments
Python, about exception handling
Memorize Python commentary 4 --Input
About Python Pyramid traversal
Key input in Python
About Python3 ... (Ellipsis object)
[Python] Chapter 01-01 About Python (First Python)
About __all__ in python
Python: Use zipfile to unzip from standard input
Standard input / output summary
Have python parse the json entered from the standard input
[Python] Change standard input from keyboard to text file
Which is better, python standard input receiving input () or sys.stdin?
[Python] Find out about pip
Cisco Memorandum _ Python config input
About Fabric's support for Python 3
Python 3.4 or later standard pip
Write standard input in code
About python objects and classes
Standard input with time limit
About Python variables and objects
Python standard unittest usage notes
About the Python module venv
Think about architecture in python
Part 1 of receiving standard input
About python beginner's memorandum function
About the enumerate function (python)
Python Input Note in AtCoder
About various encodings of Python 3
About Python, len () and randint ()
About Perl, Python, PHP, Ruby