[issue17520] Except(ValueError) on Integer returns the input value as 1

Rabcor report at bugs.python.org
Fri Mar 22 17:05:18 CET 2013


New submission from Rabcor:

I'm an amateur at best, but the issue is that if i do this.
---
try:
    num = int(input('Write a number-->'))
except(ValueError) as noint:
    print('You did not write an integer')
---
num will become 1 if i write an invalid value (like a) on the input line.

In that example code i made it will show you that. the code should be readable even if the language of what is going to be printed is not english, it converts 999 to 1 fhr bill, 4 hr coins, 1 fty coin, 4 ten coins, 1 fiv coin and 4 coins

If you need context.

I commented out my temporary solution to it (turning num into 0.1 as that's not a valid integer and i'm only working with integers.)

----------
components: Tkinter
files: Heimaverkefni5.py
messages: 184979
nosy: rabcor
priority: normal
severity: normal
status: open
title: Except(ValueError) on Integer returns the input value as 1
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file29546/Heimaverkefni5.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17520>
_______________________________________


More information about the Python-bugs-list mailing list