Describe what you have learned about acquiring standard input
【input】
afd
agdp
hj
【output】
afd
agdp
hj
for a in range(3):
c = input()
print(c)
【input】
6 90
【output】
6
90
input_line = input().split()
for a in input_line:
print(a)
【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】
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)
【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