Linked Questions

1808 votes
25 answers
2.2m views

How do I read from standard input (stdin)?
tehryan's user avatar
  • 25.2k
843 votes
22 answers
830k views

In Python, how can we find out the command line arguments that were provided for a script, and process them? Related background reading: What does "sys.argv[1]" mean? (What is sys.argv, and ...
user avatar
34 votes
4 answers
185k views

Is it possible to run first the program then wait for the input of the user in command line. e.g. Run... Process... Input from the user(in command line form)... Process...
Viin's user avatar
  • 517
6 votes
5 answers
16k views

I am implementing a small command line tool in python that needs to ask the user a couple of questions. I use raw_input('Are you male or female?') all the time. Now I would like to be able to deal ...
Hans's user avatar
  • 1,790
2 votes
3 answers
4k views

I'm trying to compare a input that the user receives that checks if the input is actually a number. Here's what I have so far: numstring = input("Choose a number between 1 and 10") and then to ...
Some Guy's user avatar
  • 411
2 votes
6 answers
11k views

I wrote a function in Python which prompts the user to give two numbers and adds them. It also prompts the user to enter a city and prints it. For some reason, when I run it in a shell, I get "name is ...
chris005's user avatar
2 votes
1 answer
45k views

I have code that manipulates data of a file that I currently have hard-coded in the script. I want to be able to prompt the user to chose the input file rather than having to hard-code it. Here is ...
P.J.'s user avatar
  • 237
0 votes
4 answers
34k views

please help me... "Read in two numbers from user input without a prompt, add them, and print the result. Hint: Use int() to convert the numbers to integers. Note: These activities may test code ...
dazedandconfused's user avatar
2 votes
4 answers
20k views

I have the following code, which is supposed to ask the user 2 file names. I get an error with the input() in the second function but not in the first, I don't understand... Here is the error : ...
user avatar
1 vote
4 answers
6k views

I have a file named myadd.py that contains only the following function: def myadd(a,b): return a+b How can I run it on Linux terminal? I am looking for something easy like this: python myadd 2,3 ...
Albert's user avatar
  • 395
2 votes
2 answers
13k views

In Java, one can write something like this: Scanner scan = new Scanner(System.in); x = scan.nextInt(); y = scan.nextDouble(); etc. What is the equivalent of this in Python 3? The input is a list of ...
tinachou28's user avatar
-2 votes
2 answers
4k views

I have an interact() function which I need to ask for a file. I already have a function load_maze(filename) which loads my text document in python. How do i get interact() to ask for my filename in ...
Anthony Do's user avatar
  • 1,429
0 votes
7 answers
810 views

Ok so I have a function I've made called DrawGraph. This one function is pretty much my whole program. DrawGraph(x, y, xv, yv, s) At the start of the program I would like to have to type in this ...
Greg Peckory's user avatar
  • 8,148
2 votes
4 answers
3k views

I just want to use os.system("dir") and also be able to save the text outputted to a variable. I tried using sys.stdout.read() but running sys.stdout.readable() returns False. Do you know how I can ...
TheTypoIsIntentoinal's user avatar
0 votes
2 answers
4k views

How can I receive input from the terminal in Python? I am using Python to interface with another program which generates output from user input. I am using subprocess.Popen() to input to the program, ...
Jonathan Ginsburg's user avatar

15 30 50 per page