About 50 results
Open links in new tab
  1. Python input () function - Stack Overflow

    Nov 11, 2016 · On Python 2, input() attempts to coerce the value to a natural Python value, so if the user inputs [1, 2], input() will return a Python list. This is a bad thing, as you will still need to validate and …

  2. Python - How to take user input and use that in function

    Jun 18, 2016 · I edited my answer, yes, you can take user input and pass it to function. In my answer, I am passing user inputs x and y to the function multiplication. Does that clarify your issue?

  3. python - How do you use input function along with def function?

    Jun 9, 2015 · When you called your function, you never assigned the value to a variable, so it has been wasted. Also, are you using Python 3 or 2.7? In python 3 using input() will return a string, and to …

  4. python - is it possible to use input () in the body of a function ...

    Oct 28, 2021 · It's fine to use input inside a function. The key is to decide which function input should be used in. It would be better to separate the pure computation from the "impure" I/O. And why are you …

  5. What's the difference between `raw_input()` and `input()` in Python 3?

    In Python 2, raw_input() returns a string, and input() tries to run the input as a Python expression. Since getting a string was almost always what you wanted, Python 3 does that with input().

  6. How to define default value if empty user input in Python?

    Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value wi...

  7. How do I use raw_input in Python 3? - Stack Overflow

    Jun 5, 2009 · As others have indicated, the raw_input function has been renamed to input in Python 3.0, and you really would be better served by a more up-to-date book, but I want to point out that there …

  8. python - How to test a function with input call? - Stack Overflow

    I have a console program written in Python. It asks the user questions using the command: some_input = input ('Answer the question:', ...) How would I test a function containing a call to input using

  9. Input function not working in Python Code - Stack Overflow

    Mar 12, 2022 · I was writing a python code in VS Code and somehow it's not detecting the input() function like it should. Suppose, the code is as simple as def main(): x= int ( input() ) print(x) if

  10. python - How to stop the input function from inserting a new line ...

    An alternative to backtracking the newline is defining your own function that emulates the built-in input function, echoing and appending every keystroke to a response variable except Enter (which will …