Python Forum
need help with making a validating function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help with making a validating function
#2
isdigit returns True if the string is all digits, but only if you call it (num.isdigit()). It's not clear exactly what you are trying to do, but if you need to see that the number is 9 digits long, you want len(num) == 9. Your atempt variable is just going to cause errors, because you never define atempt anywhere and then try to test it. I would just do a while True: loop, and break when the number is valid. I would also indent that else clause to tie it to the if, not the while.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: need help with making a validating function - by ichabod801 - Mar-28-2019, 01:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] formula for validating monetary values? kakos_k9 1 813 Dec-17-2022, 09:28 PM
Last Post: woooee
  Making a function more efficient CatorCanulis 9 1,983 Oct-06-2022, 07:47 AM
Last Post: DPaul
Question Making a copy list in a function RuyCab 1 1,842 Jul-11-2021, 02:06 PM
Last Post: Yoriz
  Making a code.py file to function, does not run hobbyist 6 2,986 Jan-27-2021, 07:50 AM
Last Post: DeaD_EyE
  Validating user input WJSwan 2 2,190 Jul-06-2020, 07:21 AM
Last Post: menator01
  making a function that writes variables (is possible?) miker2808 3 2,399 Jan-30-2020, 06:27 PM
Last Post: buran
  Validating the functionality of the application rpalakodety 1 1,813 Dec-30-2019, 07:58 PM
Last Post: ndc85430
  Validating information from .csv file before executemany mzmingle 7 4,544 Apr-15-2019, 01:40 PM
Last Post: mzmingle
  Base for making a search function SheeppOSU 1 2,355 Mar-19-2019, 11:37 PM
Last Post: Yoriz
  Making list empty after return in function dan789 10 5,869 Nov-24-2018, 11:54 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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