Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cs50 import get_int
- credit = get_int("Number:")
- na = int(str(credit)[:2])
- naa = int(na /10)
- le = len(str(credit))
- sum = 0
- while credit > 0 :
- n1 = int(credit%10)
- credit = credit/10
- n2 = int(credit%10 *2)
- credit = credit/10
- n2 = int(n2/10 +n2%10)
- sum = n1 +n2 + sum
- if sum%10 == 0 :
- if (na == 34 or na ==37) and (le ==15):
- print("AMEX")
- elif (na ==51 or na ==52 or na ==53 or na==54 or na ==55) and (le==16) :
- print("MASTERCARD")
- elif (naa %10 ==4) and (le==13 or le==16):
- print("VISA")
- else :
- print("INVALID")
- else :
- print("INVALID")
Advertisement
Add Comment
Please, Sign In to add comment