Python_Institute
PCEP-30-02 · Question #318
The following is a program to validate customer numbers. ``python customer_number = input('Enter the employee number (dd-ddd-dddd): ') parts = customer_number.split('-') valid = False if len(parts)…
The correct answer is D. There will be an AttributeError. See the full explanation below for the reasoning.
Question
The following is a program to validate customer numbers.
customer_number = input('Enter the employee number (dd-ddd-dddd): ')
parts = customer_number.split('-')
valid = False
if len(parts) == 3:
if parts[0].isdigit() and parts[1].isdigit() and parts[2].isdigit():
valid = True
print(valid)
The number may only contain numbers and dashes. The number must have the right format (dd-ddd-dddd).
What is true about this program?Options
- AThere will be no error but there will be an unwanted result.
- BThere will be a SyntaxError.
- CThe program works properly.
- DThere will be an AttributeError.
How the community answered
(28 responses)- A4% (1)
- B4% (1)
- C7% (2)
- D86% (24)
Community Discussion
No community discussion yet for this question.