Python Forum
Verify input as integer and not blank
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Verify input as integer and not blank
#1
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.
Reply
#2
int raises a ValueError if what you give it can't be converted to an integer, so handle that with try and except.
Reply
#3
Thanks for the feedback
Reply
#4
Note to use proper code tags in the future - see proper Code Tag Usage
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to verify widening conversion? quazirfan 1 601 Apr-08-2023, 07:04 AM
Last Post: Gribouillis
  How to verify the give number is valid Mekala 3 2,357 May-16-2020, 02:40 PM
Last Post: anbu23
  Unable to verify python versio ThereIsNoSpoom 2 1,762 Jan-15-2020, 09:12 AM
Last Post: DeaD_EyE
  CSV gives me blank row on PC, but not a Mac bazcurtis 2 2,741 Jan-06-2020, 08:40 AM
Last Post: buran
  Verify if .docx table of contents is updated as per document sections or not vintysaw 0 3,843 Oct-24-2019, 12:01 PM
Last Post: vintysaw
  blank space + input() ClassicalSoul 6 4,134 Mar-06-2019, 09:50 AM
Last Post: perfringo
  Mixed string,Integer input variable issue maderdash 2 2,714 Nov-06-2018, 09:46 AM
Last Post: snippsat
  Changing User Input Strings Into Set Integer Values Mario128843 3 3,121 May-01-2018, 03:32 AM
Last Post: Mario128843
  storing input as a integer help faputting 1 2,417 Feb-23-2018, 06:39 PM
Last Post: nilamo
  why does integer input give error invalid literal for int() PyPhanman 2 6,144 Apr-27-2017, 05:32 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020