In Python 3, I want to "input" multiple strings with new lines.
For example, if the strings "Apple" and "Tangerine" are broken and entered as standard, I would like to substitute the variables "a" and "b" respectively.If possible, I would like to know if there are more than three standard inputs and how to represent them in a single line.
(Standard Input)
Apple returntangerinereturn
(Results)
Replace variable a with apple
Replace variable b with tangerine
Take a line of standard input with the built-in function input()
.
a=input()
b = input()
If you do not know how many are entered (when the number is variable), it is recommended to keep the data in the list while repeating input()
.At this time, you must decide the conditions for repeated termination.
For example, if you want to continue reading EOF, you can write:
lines=[ ]
while True:
try:
lines.append(input())
except EOFError:
break
© 2025 OneMinuteCode. All rights reserved.