From ba32e344b7008a705ff374bf728f0cc4093a6062 Mon Sep 17 00:00:00 2001 From: Tokstech <138794535+Tokstech@users.noreply.github.com> Date: Sat, 28 Sep 2024 12:21:59 +0100 Subject: [PATCH] Update eCalculate.py I removed semi-colons from the code as it is not needed in current python versions. Also I made the code more interactive. The user will always be prompted the user to input a correct integer values for the code to run --- eCalc/eCalculate.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/eCalc/eCalculate.py b/eCalc/eCalculate.py index 2ec508c..c4eaf00 100644 --- a/eCalc/eCalculate.py +++ b/eCalc/eCalculate.py @@ -5,17 +5,19 @@ def CalculateE(roundVal): someE = round(math.e,roundVal); e = str(someE) someList = list(e) - return someE; + return someE - - - - -roundTo = raw_input('Enter the number of digits you want after the decimal for e: ') -try: - roundint = int(roundTo); - print CalculateE(roundint); -except: - print "You did not enter an integer"; +while True: + roundTo = input('Enter the number of digits you want after the decimal for e: ') + try: + roundint = int(roundTo) + print(CalculateE(roundint)) + + break + + except: + print("You did not enter an integer") + + continue