About 118,000 results
Open links in new tab
  1. python - User input and command line arguments - Stack

    Use 'raw_input' for input from a console/terminal. if you just want a command line argument like a file name or something e.g. $ python my_prog.py file_name.txt then you can use sys.argv... import sys print sys.argv sys.argv is a list where 0 is the program name, so in the above example sys.argv[1] would be "file_name.txt"

  2. Asking the user for input until they give a valid response

    Apr 25, 2014 · If age<=0, ask the user to input a valid number for age again, (i.e. go back to step 1.) 1.2. If age is not float or int data type, then ask user to input her/his age again (i.e. go back to step 1.) Here is the code.

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

    Jun 18, 2016 · In Python 2, you should accept user inputs with raw_input(): Check this. x=int(raw_input("Enter first number")) y=int(raw_input("Enter second number")) Please follow a proper indentation plan with python: Also, you did not accept the variables while defining your function, and learn how to use print:

  4. Python: How to keep repeating a program until a specific input is ...

    inp = raw_input() # Get the input while inp != "": # Loop until it is a blank line inp = raw_input() # Get the input again Note that if you are on Python 3.x, you will need to replace raw_input with input .

  5. python - How do I restart a program based on user input ... - Stack ...

    The inner while loop loops until the input is either 'y' or 'n'. If the input is 'y', the outer while loop starts again (continue keyword skips the remaining code and goes straight to the next iteration). If the input is 'n', the outer while loop breaks and the program ends. Note: I'm using input() in Python 3. In Python 2, use raw_input().

  6. Python - Ask for input multiple times til a certain input disables it

    Apr 7, 2016 · The function will prompt for input in which user input an element. That element will be added to the list. When user input a certain element i.e. a string, the function returns the list. So when I run the function, it should be something like this: Input an element: 100 Input an element: 200 Input an element: 300 Input an element: Stop [100 ...

  7. Quick and easy file dialog in Python? - Stack Overflow

    Feb 17, 2012 · Using tkinter (python 2) or Tkinter (python 3) it's indeed possible to display file open dialog (See other answers here). Please notice however that user interface of that dialog is outdated and does not corresponds to newer file open dialogs available in Windows 10.

  8. python - User input in dialog box - Stack Overflow

    May 21, 2018 · This only shows the dialogue box and you can't provide an input entry. import ctypes # An included library with Python install. ctypes.windll.user32.MessageBoxW(0, "Your text", "Your title", 1)

  9. How to run the math from an input in python - Stack Overflow

    Feb 28, 2017 · While eval operates in a very general context and so much scope for introducing security issues ast.literal_eval is intended to evaluate string literals only and so has a far narrower and hence safer scope.

  10. python - Prompt user for file input - Stack Overflow

    This prompts the user for text input and returns it as a string. In your case, this will prompt for a file path to be input. If you add an argument to this function, it prints something without a newline before input is requested, for example:

Refresh