A programmer has written a function to validate a new password. The rules are:
- Password must be at least 8 characters long.
- Password must not be empty.
The code contains one
Syntax Error and one
Logic Error.
01 def validate_password(pWord):
02 if len(pWord) == 0:
03 print("Error: Password cannot be empty")
04 return False
05 elif len(pWord) < 8
06 print("Error: Password too short")
07 return True
08 else:
09 return True
(a) Identify the line number of the
Syntax Error and write the corrected line.
[2]
Line Number: .............
Correction: ............................................................................................
(b) Identify the line number of the
Logic Error and explain why it is an error.
[2]
Line Number: .............
Explanation: ...........................................................................................