Python Forum

Full Version: Verify input as integer and not blank
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
parallel = self.gui2.parallel_config()
parallel_text = int("".join(map(str, parallel)))

if parallel_text != int and parallel_text != '':
QMessageBox.warning(self, '', 'Please input integer only in parallel and series', buttons=QMessageBox.Yes)
return

parallel is a list.
I could not get it work.
How could I verify the the input as integer only, not other?
The problem for 'parallel' is a list.
Even I input integer, it still show warning. Thats why I change the list to integer.
Please help, thanks.
int raises a ValueError if what you give it can't be converted to an integer, so handle that with try and except.
Thanks for the feedback
Note to use proper code tags in the future - see proper Code Tag Usage