[Solved] ValueError: invalid literal for int() with base 10: ” python [closed]


The problem is because int tries to convert '' to a base 10 number, which is not possible. Thats why it is failing. You are getting the default '' if the value is not there like this

form.getvalue('opt_12', '')

instead of that use a sentinel value like this

form.getvalue('opt_12', '0')

Even better, you can convert them to numbers as and when you get them from the form like this

res12 = int(form.getvalue('opt_12', '0'))
...
...
...

3

solved ValueError: invalid literal for int() with base 10: ” python [closed]