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
547 PHP ssh2_scp_send fails to send files as intended
690 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
546 Understanding How to Configure Google API Key
546 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.