(self)
| 43 | return message |
| 44 | |
| 45 | def validate(self): |
| 46 | # double every second digit from right to left |
| 47 | sum_ = 0 |
| 48 | crd_no = self.card_no[::-1] |
| 49 | for i in range(len(crd_no)): |
| 50 | if i % 2 == 1: |
| 51 | double_it = int(crd_no[i]) * 2 |
| 52 | |
| 53 | if len(str(double_it)) == 2: |
| 54 | sum_ += sum([eval(i) for i in str(double_it)]) |
| 55 | |
| 56 | else: |
| 57 | sum_ += double_it |
| 58 | |
| 59 | else: |
| 60 | sum_ += int(crd_no[i]) |
| 61 | |
| 62 | if sum_ % 10 == 0: |
| 63 | response = "Valid Card" |
| 64 | else: |
| 65 | response = "Invalid Card" |
| 66 | |
| 67 | return response |
| 68 | |
| 69 | @property |
| 70 | def checksum(self): |
no outgoing calls
no test coverage detected