🌐
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.
Discussions

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
🌐 r/learnpython
15
22
August 17, 2022
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
🌐 r/learnpython
11
25
April 12, 2023
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
🌐 r/learnpython
2
0
March 9, 2022
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
🌐 r/learnpython
18
22
August 16, 2021
🌐
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.
🌐
Career Karma
careerkarma.com › blog › python › python input: a step-by-step guide
Python Input: A Step-By-Step Guide | Career Karma
December 1, 2023 - Input(), a built-in function in Python, allows coders to receive information through the keyboard, which they can process in a Python program. In this tutorial, we are going to break down the basics of Python input().
🌐
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.
🌐
Unstop
unstop.com › home › blog › python input() function explained in detail (+code examples)
Python input() Function Explained In Detail (+Code Examples)
November 28, 2024 - The input() function in Python takes single-line, multi-line or multiple input values from the user. However, it always returns the input as a string.
Find elsewhere
🌐
Medium
medium.com › @ujeevanprasad › getting-started-with-user-input-in-python-the-input-function-explained-5246e9e0872f
Getting Started with User Input in Python: The “input()” Function Explained. | by Ujeevanprasad | Medium
December 7, 2025 - The “input()” function is a built-in Python function designed to get user input. When “input()” is called it displays an optional prompt message to the user and then waits for them to type something and press Enter.
🌐
DEV Community
dev.to › vayolapradeep › python-input-function-detailed-explanation-3898
Python input() Function - Detailed Explanation - DEV Community
February 12, 2025 - The input() function in Python is used to take user input from the keyboard. It allows your program to interact with the user by prompting them to enter data, which can then be processed or stored in variables.
🌐
PYnative
pynative.com › home › python › python input: take input from user
Python Input(): Take Input From User [Guide]
February 23, 2024 - In Python, Using the input() function, we take input from a user, and using the print() function, we display output on the screen.
🌐
W3Schools
w3schools.com › python › python_user_input.asp
Python User Input
The Python input() function has a prompt parameter, which acts as a message you can put in front of the user input, on the same line: ... You can add as many inputs as you want, Python will stop executing at each of them, waiting for user input: ...
🌐
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.
🌐
Tutorialspoint
tutorialspoint.com › python › python_input_function.htm
Python input() Function
The Python input() function returns a String containing the user input.
🌐
EyeHunts
tutorial.eyehunts.com › home › what does the python input() function do | basics
What does the Python input() function do | Basics
November 22, 2021 - The Python input() function allows a user to insert a value into a program. It takes an input value from the user and returns a string value
🌐
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
🌐
Python Central
pythoncentral.io › python-input-function-a-complete-guide
Python Input() Function: A Complete Guide | Python Central
March 1, 2024 - In Python, the input() function enables you to accept data from the user. In this brief guide, you'll learn how to use the input() function.
🌐
Reddit
reddit.com › r/learnpython › can anyone please explain how input works in python?
r/learnpython on Reddit: Can anyone please explain how input works in python?
August 17, 2022 -

So, I wanted to make a code where a student enters his name, and then he is shown if he passed, didn’t pass but can retry or ultimately failed along with his average grade. (I don’t know how to do the along with his/her specific average grade).

And my code looks like this:

[passed = ["Bill", "Andrew", "Son", "Bella"]

Andrew_AG = ((5+2+4+4+5+5+4+5)/8)

Bill_AG = ((5+5+5+5+4+3+5+5)/8)

Son_AG = ((5+5+5+5+5+5+5+5)/8)

Bella_AG = ((5+5+5+5+4+3+5+5)/8)

re_try = ["Irina", "John", "Tommy"]

Tommy_AG = ((5+3+4+2+2+3+3+3)/8)

John= ((3+4+4+3+2+2+3+4)/8)

Irina_AG = ((2+4+4+4+2+2+3+3)/8)

failed = ["Ned", "Bet"]

Ned_AG = ((1+1+2+5+2+2+3+5)/8)

Bet_AG = ((1+2+2+3+2+2+3+1)/8)

if input ("What's your name?") == (("Bill") or ("Andrew") or ("Son") or ("Bella")): print ("You passed")

elif input ("What's your name?") == (("Irina") or ("John") or ("Tommy")): print ("You didn't pass, but you can re-try")

elif input ("What's your name?") == (("Ned") or ("Bet")): print ("You failed and you may not re-try")

else: print ("You're not on the list")

But unfortunately I’ve been running into mistakes where even if I enter the correct name it would ask me “What’s your name?” 3 times until displaying “You’re not on the list”. So I guess it’s something wrong with my understanding of Input command

(I’ve been coding only for 1 week so don’t blame me for bad code or dumb question)

Top answer
1 of 8
18
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.
2 of 8
4
[passed = ["Bill", "Andrew", "Son", "Bella"] That is not valid Python. The square bracket at the beginning of the line needs to be removed. That said, the problem here isn't input(), it's that your multiple conditions aren't set up correctly. This is covered in the subreddit FAQ: https://www.reddit.com/r/learnpython/wiki/faq/#wiki_variable_is_one_of_two_choices.3F Also, you should only take the name input once, save it to a variable, then check that variable against your lists of names. As your code is currently written you may get asked for a name multiple times.
🌐
Oreate AI
oreateai.com › blog › understanding-the-input-function-in-python-a-users-guide › fe2b42381c28ef63bc747acb1251e02c
Understanding the Input() Function in Python: A User's Guide - Oreate AI Blog
December 30, 2025 - Explore how Python's input() function facilitates user interaction by prompting for data entry and returning responses as strings.