Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Equivalent to System('PAUSE')

I have been coding a basic calculator in python 3.3 and I want to be able to run it in command window.

but as soon as i get to the end it shuts the windows before I have time to view the final answer.

so I was wondering if there is an equivalent to the c++ System('PAUSE') command to tell it not to go any further until the user is ready.

Here is my calculator code:

print('Your Very Own Basic Calculator')
first_num = int(input('Please Enter The First Number: '))
second_num = int(input('Please Enter The Second Number: '))
Equation = input('What would you like to do, multiplication, division, subtraction or     
if Equation == ('*'):
addition? *, /, -, +')
    print('The Answer is',first_num * second_num)
elif Equation == ("/"):
    print('The Answer is',first_num / second_num)
elif Equation == ('-'):
    print('The Answer is',first_num - second_num)
elif Equation == ('+'):
    print('The Answer is',first_num + second_num)

thanks

like image 449
MaxxB Avatar asked Mar 17 '14 22:03

MaxxB


2 Answers

Use input() on p3k or raw_input() on p2.7x - it will read anything from stdin, so it will wait until user is ready.

like image 180
Filip Malczak Avatar answered Oct 06 '22 11:10

Filip Malczak


as of today this is working under win7 :

import os
(...)
os.system("PAUSE")

Watch out the caps in the snippet, pause is not PAUSE.

like image 29
Jean-Christophe Gay Avatar answered Oct 06 '22 11:10

Jean-Christophe Gay