Python input issue -
this question has answer here:
- how can read inputs integers? 14 answers
hello have program must scan , save barcodes variable. working except fact getting error whenever bar code starts 0.
here sample of code:
user_code = eval(input("hello please enter coupon code: ")) i must use eval(input(.... because muse pass integer openpyxl(to store variables in excel file)
but everytime barcode starts 0 error:
hello please enter coupon code: 0555 traceback (most recent call last): file "c:/users/hp/documents/pycharmprojects/coupon_scanner/coupon_scanner_v5.py", line 149, in <module> user_code = eval(input("hello please enter coupon code: ")) file "<string>", line 1 0555 ^ syntaxerror: invalid token
instead of due security reason eval considered dangerous function , integer 0 known octal integer.like wise integer x in know hexa integer type conversion hapens
user_code = eval(input("hello please enter coupon code: ")) try this
user_code = int(input("hello please enter coupon code: "))
Comments
Post a Comment