How do I return a value from a function in python that has an exception if it fails -
i have check when user enters values. example if user enters value outside range 250-10000 should show message warning them have entered bad value , renter value. code have works if enter correct value. if enter incorrect value message if enter correct value how fc in main(). open positive feedback!. in advance!
import ctypes def build_fc(): print "please enter fc between 250-10000:" fc_string_input = raw_input() fc_float = float(fc_string_input) if (fc_float)>=250 , (fc_float<=10000): return float(fc_string_input) else: setup_fc_error_message() build_fc() def setup_fc_error_message(): lines = ['fc out of range: please enter value 250-10000:'] messagebox = ctypes.windll.user32.messageboxa messagebox(none, "\n".join(lines), 'setup info', 0) def main(): fc = build_fc() print fc if __name__ == "__main__": main()
instead of,
else: setup_fc_error_message() build_fc()
try:
else: setup_fc_error_message() return build_fc()
Comments
Post a Comment