← Back to challenges

Mod 10 Algorithm

PythonHardalgorithmslogicvalidation

Instructions

Create a function that takes a number and checks whethers the given number is a valid credit card number using Luhn Algorithm. The return value is boolean.

Examples

valid_credit_card(4111111111111111) ➞ True
# Visa Card

valid_credit_card(6451623895684318) ➞ False
# Not a valid credit card number.

valid_credit_card(6451623895684318) ➞ False

Notes

  • American Express/VISA/Discover/Diner Club may be the credit card type.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.