Python Forum
Runs perfect in Python but fails to print last statement when converted to .exe. Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Runs perfect in Python but fails to print last statement when converted to .exe. Help
#1
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)
Reply
#2
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...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you so much!
Reply
#4
You can add input('Enter') at the end to hold the window open.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Importing a function from another file runs the old lines also dedesssse 6 654 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  Why doesn't this print statement work? stylingpat 10 1,747 Mar-23-2021, 07:54 PM
Last Post: buran
  Embedded python fails to compile on Raspberry Pi tryfon 2 1,085 Dec-22-2020, 02:06 PM
Last Post: tryfon
  how to change the range of read CSV file every time python file runs greenpine 6 1,429 Dec-08-2020, 10:11 PM
Last Post: greenpine
  Perfect numbers Vidar567 2 770 Nov-23-2020, 10:29 PM
Last Post: Vidar567
  pip3 install opencv-python fails on 'skbuild' Pedroski55 2 2,861 Sep-15-2020, 11:33 AM
Last Post: snippsat
  Python 3.6.10 fails when running a localized script. Mikee 2 900 Jul-09-2020, 10:25 PM
Last Post: Mikee
  How to create an Excel app that runs Python? felipe0216 3 1,000 May-31-2020, 01:19 AM
Last Post: ibutun
  cannot build python 3.8.2 (make test fails on test_imprtlib) borabora 1 1,252 May-08-2020, 09:10 PM
Last Post: Larz60+
  Taking brackets out of list in print statement pythonprogrammer 3 1,221 Apr-13-2020, 12:25 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020