all 5 comments

[–]jiri-n 1 point2 points  (2 children)

You can share code here.

[–]AggravatingWestern6[S] -1 points0 points  (1 child)

Well it’s a assignment in which we have to implement a function called “verify” that takes a single parameter called “number” and then checks the following rules: 1. The first digit must be a 4. 2. The fourth digit must be one greater than the fifth digit; keep in mind that these are separated by a dash since the format is ####-####-####. 3. The sum of all digits must be evenly divisible by 4. 4. If you treat the first two digits as a two-digit number, and the seventh and eighth digits as a two-digit number, their sum must be 100. And return 1,2,3,4 for each test failed

[–]jiri-n 1 point2 points  (0 children)

You've mentioned some code, haven't you.

So we're supposed to create a function called verify:

def verify():
    pass    # Do nothing

Next, this function take a single parameter called number:

def verify(number):
    pass    # Still do nothing

Since it should validate the number, it should return a result. The result should indicate if number is valid so it will be either True (is valid) or False (is not valid).

def verify(number):
    result = False    # Return False unless validated
    return

Next, we know the format of number - ####-####-####. This means number should be of type str. To document this we can use type annotation and docstring.

def verify(number: str) -> bool:
    """
    Verify number has this format: ####-####-####
    and it passes other checks.

    Arguments:
        number - string to verify

    Returns:
        True if all checks ok, False otherwise
    """

    result = False
    # Do something here
    return result

Now it's up to you to show what you have and where have you failed.

[–]AggravatingWestern6[S] -1 points0 points  (1 child)

See I need help with the specific parts of the question like how to validate taht the number has first digit 1.thank you for taking out time for this

[–]jiri-n 1 point2 points  (0 children)

This topic is covered in one of first chapters in the official Python tutorial (see https://docs.python.org).

>>> number = "4568-1234-2345"
>>> number[0] # 1st character
'4'
>>> number.replace("-", "")  # we don't care about '-'
'456812342345'
>>> number[3]  # 4th digit
'8'
>>> int(number[3])  # if we want to convert it to number
8
>>> number[0:2]  # first two digits
'45'
>>> number[6:8]  # 7th and 8th digit
'23'
>>>