Python Forum

Full Version: Runs perfect in Python but fails to print last statement when converted to .exe. Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This code runs perfect in Python but fails to print last statement(printing calculation) when converted to .exe using pyinstaller. Please Help!

# Defining a function to print error when input is wrong.
def exp():
print('Error! Enter Valid Number')
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
p=float(input('ENTER SUM'))
break
except:
exp()
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
r=float(input('ENTER RATE'))
break
except:
exp()
# Unless entered value is correct ask to enter correct value.
# If the value is wrong call the function
while True:
try:
fz=float(input('ENTER TIME IN MONTH'))
break
except:
exp()
t=(fz/12)
# Print the calculation.
print('Interest=Rs',p*t*r/100,'\nAmount to pay=Rs',p+p*t*r/100)
How do you run the exe? If you just click on it, it will close the window immediately after printing the last line and you just don't see it.
Open cmd, run the exe via command line.
or add a line to wait for user input before finishing the execution.


on a side note - you left that repeating code...
Thank you so much!
You can add input('Enter') at the end to hold the window open.