python - Unindent error and input number limit -



python - Unindent error and input number limit -

i making calculator (using tkinter) , need have limit if user enters input of more 999, error message appears , numbers not calculated (it school project). when run script below, @ school appears blank gui , on home computer says 'unindent not match outer indentation level'. how can solve this? p.s. using python 3.3.2

def calc(self): try: self.display.set(self.validate_result(eval(self.display.get()))) self.need_clr = true except: showerror('operation error', 'illegal operation') self.display.set('') self.need_clr = false def validate_result(self, result): if result >= 1000: raise valueerror('result big!') else: homecoming result

python uses indentation distinguish levels of scope.

here code seems exclusively indented, python thinks code in inner scope, , tries find outer scope contains it, there isn't any.

you should seek indentation :

def calc(self): try: ... def calc(self): try: ...

edit : also, seem have other indentation problems in sec function. must align except try, , there 1 space missing before if result >= 1000:.

python python-3.3

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -