SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = input('Input your credit card number: ')
  2.  
  3.  
  4.  
  5. def legitcheck(n):
  6.     l = 0
  7.     s1 = []
  8.     s2 = []
  9.     if len(n) == 13 or len(n) == 16:
  10.  
  11.         for i in range(len(n) - 2, -1, -2):
  12.             s = int(n[i]) * 2
  13.             if s > 10 and not s == 10:
  14.                 l = 1 + s % 10
  15.                 s1.append(l)
  16.             if s == 10:
  17.                 s1.append(1)
  18.             if s < 10:
  19.                 s1.append(s)
  20.         summa1 = sum(map(int, s1))
  21.  
  22.         for i in range(len(n) - 1, -1, -2):
  23.             s2.append(n[i])
  24.         summa2 = sum(map(int, s2))
  25.  
  26.         grand_summa = summa1 + summa2
  27.  
  28.         if grand_summa % 10 == 0:
  29.             print('Your card is valid')
  30.         else:
  31.             print('**fake card is being detected**')
  32.     else:
  33.         print("*invalid card*")
  34.  
  35.  
  36. legitcheck(n)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top