+ 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
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)
+ 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 (:
0
ok ty
0
i mean read the input