Python Forum
Need help with isdigit() and isalpha() function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with isdigit() and isalpha() function
#3
You are trying to do too many things at once. Although you will get the skills to combine some of these processes, I strongly suggest you tackle the requirements one at a time, like this...
def main():
    enterstr = input("Enter String: ")
    valid_string = True
    """ First test - is the length exactly 9 """
    if len(enterstr) != 9 :
    """ Print the error message and change the flag"""
    """ Will leave the first letter check to you
        Next must contain 7 digits """
    digit_count = 0
    for index in range(0,8):
        if enterstr[index].isdigit():
            digit_count += 1
    """Now check to see if the digit count passes, print error if not, adjust the flag.
        """You can write the rest from here """
        
main()
Reply


Messages In This Thread
RE: Need help with isdigit() and isalpha() function - by jefsummers - Jul-22-2019, 02:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with isdigit function Omegax77 2 3,036 Jun-30-2018, 06:48 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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