GeeksforGeeks
geeksforgeeks.org › python › python-input-function
Python input() Function - GeeksforGeeks
The input() function in Python is used to take input from the user.
Published: September 18, 2025
W3Schools
w3schools.com › python › ref_func_input.asp
Python input() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The input() function allows user input.
Can anyone please explain how input works in python?
So I guess it’s something wrong with my understanding of Input command Kind of, but also no. The reason the code asks for input three times is because Each if/elif calls the function separately, and None of the conditions are true. The reason why the conditions fail is not because of input, but because you've misunderstood what the or-operator does here. The code isn't comparing the input to each of the listed cases, instead, if input ("What's your name?") == (("Bill") or ("Andrew") or ("Son") or ("Bella")): print ("You passed") is actually read by Python as if input("What's your name?") == "Bill": print ("You passed") due to short-circuiting. or is roughly equivalent to def my_or(left, right): if left: return left return right and because all non-empty strings are truthy, Python simply takes the first one and ignores the rest. So, how should you write this? My suggestion; use a tuple or a set and check inclusion with in: name = input("What's your name?") if name in {"Bill", "Andrew", "Son", "Bella"}: print("You passed") The rest of the conditions should use the already asked input, stored in name in my example. More on reddit.com
What was the design decision behind why input() always returns a string in Python?
The short answer is "because input takes input from the keyboard, and what the keyboard outputs are characters." But, of course, we could just try to coerce every input string into a float, and if that doesn't work, then coerce it to an integer, and if that doesn't work, it must be a string. Right? You're assuming that an interpretable sequence of digits and periods should always be numeric. What if it's part of an IP address? What if it's an [accession number]( https://en.wikipedia.org/wiki/Accession_number_(cultural_property) )? "1992.10" isn't the same accession number as "1992.1", but as floats they're ambiguous. Not everyone uses periods as a decimal separator; commas are commonplace outside of the US. Why stop with numerics? There are lots of literal types - lists, dictionaries, sets, etc. There's even math - should we interpret "19 - 6" as a string, or as the number 13, and why should we do so? You're not wrong to think "well, actually we should try to evaluate any inputted string as a Python literal, what a convenience that would be" and indeed they agreed with you in Python 2. That's the behavior of input in Python 2, it attempts to evaluate the input to arrive at a value. The result was a ton of errors that beginners didn't really understand, because input doesn't say that it attempts to evaluate all input, except in the documentation and beginners don't read that. But beginners are the only ones who write code using input. That's Python training wheels - real programs don't need it, they either expose a GUI for input or they take their input as command-line arguments, not via prompts. In any case, what people mostly did was use raw_input instead of input in Python 2 to disable the implicit evaluation, since it's almost never what anyone actually needed. So the evaluating version of input was bad - it was more likely to break, and when it broke, it broke for the programmers least likely to understand why. In Python 3, the evaluating version of input was replaced by raw_input's non-evaluating version, raw_input went away altogether, and now there's no ambiguity about what input does or doesn't do. So, we ran the natural experiment - the reason input doesn't coerce to anything besides a string is that nobody actually wants it to. More on reddit.com
Should I use input() within functions?
That is correct. As a general rule of thumb, your functions shouldn't care where the data is coming from. As soon as you use input within a function, that function can only ever be used to take data from input; even if it doesn't actually care where the data is coming from. This means this function can't be used if the data is coming from, say, the disk, or from over the network. In other words, you make the function less useful by enforcing where it gives/takes data to/from. Functions should take data, and give back data. Ideally, avoid taking input via side effects (like input), and avoid giving data back via side effects (like mutating globals). At some point in your program, you obviously need to call input (or wherever else you're getting data from), but the point where IO happens should be somewhat isolated. The IO code takes/gives data from/to the outside world, and passes that data to the pure functions that process it (and those pure functions ideally make up the majority of your code). And I'm not sure where you'd best learn about guidelines like this. I know of it from experience, and because I know Haskell. Haskell enforces this "rule" at the type-system level. The type-system actually prevents you from calling Haskell's equivalent of input in any old function unless you're willing to contaminate your entire program with IO, or use the unsafe backdoor that allows it. More on reddit.com
Can somebody ELI5 functions with inputs
Think of it as the literal same thing as math. f(x) -> some something with x and give it back. def(x) -> do something with x and return it. More on reddit.com
06:05
How to Use the input() Function in Python - YouTube
The Input() Function with Int() | What is input function in python
03:49
49. User Input in Python | input() function in Python - YouTube
09:17
The Python Input Function - YouTube
06:16
Python Programming - Basic Input and Output - print and input ...
01:35
❇️ Python Input Function - YouTube
Stanford CS
cs.stanford.edu › people › nick › py › python-input.html
input()
The print() function makes it easy to send your data as text to standard out (see also: print()). The Python function input() goes the other direction, letting the user type something that goes in a Python variable.
Nanyang Technological University
libguides.ntu.edu.sg › python › input
1.7 Input function - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
August 26, 2026 - In Python, we request user input using the input() function. Syntax · message = input("This is where you type in your input request: ") This set of code is requesting for user input, and will store it in the message variable. Note: Inputs are automatically saved as strings.
Programiz
programiz.com › python-programming › methods › built-in › input
Python input()
The input() function takes input from the user and returns it. In this tutorial, we will learn about the Python input() function with the help of examples.
WsCube Tech
wscubetech.com › resources › python › input-function
Python Input Function: With Syntax & Examples
August 6, 2026 - Learn all about the Python input() function with examples. Understand syntax, take string and numeric inputs, and handle data type casting easily.
Codecademy
codecademy.com › docs › python › built-in functions › input()
Python | Built-in Functions | input() | Codecademy
October 24, 2022 - Prompts the user for data and returns it as a string.
Tutorialspoint
tutorialspoint.com › python › python_input_function.htm
Python input() Function
The Python input() function returns a String containing the user input.
GeeksforGeeks
geeksforgeeks.org › python › input-and-output-in-python
Input and Output in Python - GeeksforGeeks
The print() function is used for output in various formats and the input() function enables interaction with users. Python's input() function is used to take user input.
Published: 3 weeks ago
Programming Line
learn.programmingline.com › home › python user input
Python User Input: input() Explained (with Examples)
July 18, 2026 - This lesson explains exactly how ... does three things in sequence: it prints an optional prompt string to the screen, it pauses your program and waits for the user to type something and press Enter, and then it returns whatever was typed....