Advertisement
v1s

taking user input without the input() function

v1s
Sep 18th, 2022
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | Source Code | 0 0
  1. import sys
  2.  
  3. # underscore added to not be confused with the builtin input function
  4. def _input(prompt=None, /):
  5.     if prompt:
  6.         print(prompt, end="", flush=True)
  7.     line = sys.stdin.readline()
  8.     if not line:
  9.         raise EOFError
  10.     if line[-1] == '\n':
  11.         line = line[:-1]
  12.     return line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement