+ 1

Is there a built in function that can read a line? Go to description for details

lets say I want the user to pick a number between 1 and 1000. I just want it to read the line without having to do a bunch of if statements. sys.stdin.readline does not work

14th Jul 2017, 1:10 AM
privrax.
privrax. - avatar
4 Respostas
+ 6
Python doesnt have a direct method for this like c++, this seems like the closest you can get to simulating it: import sys for line in sys.stdin: for var in line.split(): print(var)
14th Jul 2017, 8:08 AM
Maya
Maya - avatar
+ 6
Oh, also there is such a built - in function: x = input("number: ") print(x) Guess it was way too early in the morning for me to remember that earlier (:
14th Jul 2017, 11:29 AM
Maya
Maya - avatar
0
ok ty
30th Jul 2017, 10:04 PM
privrax.
privrax. - avatar
0
i mean read the input
30th Jul 2017, 10:04 PM
privrax.
privrax. - avatar