TORONTO KIDS COMPUTER CLUB | Aurora Monday 18:30 Python Homework 20.05.04.
17464
post-template-default,single,single-post,postid-17464,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Monday 18:30 Python Homework 20.05.04.

08 May Aurora Monday 18:30 Python Homework 20.05.04.

Question:

Make a program to verify whether the credit card numbers from ABCD Bank are valid or not.
A valid credit card from ABCD Bank has the following characteristics:

  • It must start with a 4, 5 or 6.
  • It must contain exactly 16 digits.
  • It must only consist of digits (0-9).
  • It may have digits in groups of 4, separated by one hyphen “-“.
  • It must NOT use any other separator like ‘ ‘ , ‘_’, etc.
  • It must NOT have 4 or more consecutive repeated digits.

Examples:
Valid Credit Card Numbers:

4253625879615786
4424424424442444
5122-2368-7954-3214

Invalid Credit Card Numbers:

42536258796157867       #17 digits in card number → Invalid
4424444424442444        #Consecutive digits are repeating 4 or more times → Invalid
5122-2368-7954 – 3214   #Separators other than ‘-‘ are used → Invalid
44244×4424442444        #Contains non digit characters → Invalid
0525362587961578        #Doesn’t start with 4, 5 or 6 → Invalid


Sample Input 1:
4123456789123456

Sample Output 1:
Valid

Sample Input 2:
5123-4567-8912-3456

Sample Output 2:
Valid

Sample Input 3:
61234-567-8912-3456

Sample Output 3:
Invalid

Sample Input 4:
5133-3367-8912-3456

Sample Output 4:
Invalid

Sample Input 5:
5123 – 3567 – 8912 – 3456

Sample Output 5:
Invalid
No Comments

Sorry, the comment form is closed at this time.