Given a credit card number we can determine who the issuer/vendor is with a few basic knowns.

```if:python
Complete the function `get_issuer()` that will use the values shown below to determine the card issuer for a given card number. If the number cannot be matched then the function should return the string `Unknown`.
```
```if-not:python
Complete the function `getIssuer()` that will use the values shown below to determine the card issuer for a given card number. If the number cannot be matched then the function should return the string `Unknown`.
```
```if:typescript
Where `Issuer` is defined with the following enum type.
~~~typescript
enum Issuer {
  VISA = 'VISA',
  AMEX = 'AMEX',
  Mastercard = 'Mastercard',
  Discover = 'Discover',
  Unknown = 'Unknown',
}
~~~
```

```markdown
| Card Type  | Begins With          | Number Length |
|------------|----------------------|---------------|
| AMEX       | 34 or 37             | 15            |
| Discover   | 6011                 | 16            |
| Mastercard | 51, 52, 53, 54 or 55 | 16            |
| VISA       | 4                    | 13 or 16      |
```

```if:c,cpp
**C/C++ note:** The return value in C is not freed.
```

## Examples

```if-not:python
~~~js
getIssuer(4111111111111111) == "VISA"
getIssuer(4111111111111) == "VISA"
getIssuer(4012888888881881) == "VISA"
getIssuer(378282246310005) == "AMEX"
getIssuer(6011111111111117) == "Discover"
getIssuer(5105105105105100) == "Mastercard"
getIssuer(5105105105105106) == "Mastercard"
getIssuer(9111111111111111) == "Unknown"
~~~
```
```if:python
~~~py
get_issuer(4111111111111111) == "VISA"
get_issuer(4111111111111) == "VISA"
get_issuer(4012888888881881) == "VISA"
get_issuer(378282246310005) == "AMEX"
get_issuer(6011111111111117) == "Discover"
get_issuer(5105105105105100) == "Mastercard"
get_issuer(5105105105105106) == "Mastercard"
get_issuer(9111111111111111) == "Unknown"
~~~
```

Source: codewars | Difficulty: EASY

Starter code: def get_issuer(number):
	

Solutions:
def get_issuer(number):
	s = str(number)
	return 'AMEX' if len(s) == 15 and s[:2] in ('34', '37') else 'Discover' if len(s) == 16 and s.startswith('6011') else 'Mastercard' if len(s) == 16 and s[0] == '5' and (s[1] in '12345') else 'VISA' if len(s) in [13, 16] and s[0] == '4' else 'Unknown'


VENDORS = [['AMEX', (34, 37), (15,)], ['Discover', (6011,), (16,)], ['Mastercard', range(51, 56), (16,)], ['VISA', (4,), (13, 16)]]

def get_issuer(number):
	return next((vendor[0] for vendor in VENDORS if len(str(number)) in vendor[2] and any((str(number).startswith(str(start)) for start in vendor[1]))), 'Unknown')


import re
REGEX = re.compile('\n(?P<AMEX>3[47]\\d{13}$) |\n(?P<Discover>6011\\d{12}$) |\n(?P<Mastercard>5[1-5]\\d{14}$) |\n(?P<VISA>(?:4\\d{15}|4\\d{12})$)', re.VERBOSE)

def get_issuer(card_num):
	try:
		return next((k for (k, v) in REGEX.match(str(card_num)).groupdict().items() if v is not None))
	except AttributeError:
		return 'Unknown'


def get_issuer(number):
	card = str(number)
	nums = len(card)
	if card[:2] in ('34', '37') and nums == 15:
		return 'AMEX'
	elif card[:4] == '6011' and nums == 16:
		return 'Discover'
	elif 51 <= int(card[:2]) <= 55 and nums == 16:
		return 'Mastercard'
	elif card[0] == '4' and nums in (13, 16):
		return 'VISA'
	return 'Unknown'


ISSUERS = {((34, 37), (15,)): 'AMEX', ((6011,), (16,)): 'Discover', ((51, 52, 53, 54, 55), (16,)): 'Mastercard', ((4,), (13, 16)): 'VISA'}

def get_issuer(number):
	return next((issuer for ((starts, lengths), issuer) in ISSUERS.items() if str(number).startswith(tuple(map(str, starts))) and len(str(number)) in lengths), 'Unknown')


from collections import namedtuple
Issuer = namedtuple('Issuer', 'name, begins, length')

def get_issuer(number):
	issuers = [Issuer('AMEX', [34, 37], [15]), Issuer('Discover', [6011], [16]), Issuer('Mastercard', [51, 52, 53, 54, 55], [16]), Issuer('VISA', [4], [13, 16])]
	number_str = str(number)
	for issuer in issuers:
		if any([number_str.startswith(str(n)) for n in issuer.begins]) and len(number_str) in issuer.length:
			return issuer.name
	return 'Unknown'


def get_issuer(number):
	number = number // 1000000000000
	if number == 4:
		return 'VISA'
	if number == 6011:
		return 'Discover'
	number = number // 10
	if number == 34 or number == 37:
		return 'AMEX'
	if 50 < number // 10 < 56:
		return 'Mastercard'
	if number // 100 == 4:
		return 'VISA'
	return 'Unknown'


from typing import Tuple

class Card:

	def __init__(self, name: str, begins_with: Tuple[int, ...], number_length: Tuple[int, ...]):
		self.name = name
		self.begins_with = list(map(str, begins_with))
		self.number_length = number_length

	def is_valid(self, number: str) -> bool:
		return any((number.startswith(b) for b in self.begins_with)) and len(number) in self.number_length
CARDS = (Card('AMEX', (34, 37), (15,)), Card('Discover', (6011,), (16,)), Card('Mastercard', (51, 52, 53, 54, 55), (16,)), Card('VISA', (4,), (13, 16)))

def get_issuer(number: int):
	n = str(number)
	return next((c.name for c in CARDS if c.is_valid(n)), 'Unknown')


from re import match

def get_issuer(number):
	number = str(number)
	if match('^3[4|7]\\d{13}$', number):
		return 'AMEX'
	if match('^6011\\d{12}$', number):
		return 'Discover'
	if match('^5[1-5]\\d{14}$', number):
		return 'Mastercard'
	if match('^4(\\d{12}|\\d{15})$', number):
		return 'VISA'
	return 'Unknown'


def get_issuer(n):
	n = str(n)
	if n[:1] == '4' and (len(n) == 13 or len(n) == 16):
		return 'VISA'
	if (n[:2] == '34' or n[:2] == '37') and len(n) == 15:
		return 'AMEX'
	if n[:4] == '6011' and len(n) == 16:
		return 'Discover'
	if n[:1] == '5' and int(n[1]) < 6 and (len(n) == 16):
		return 'Mastercard'
	return 'Unknown'


import re

def get_issuer(number):
	for (n, r) in (('AMEX', '3[47].{13}'), ('Discover', '6011.{12}'), ('Mastercard', '5[1-5].{14}'), ('VISA', '4(...){4,5}')):
		if re.fullmatch(r, str(number)):
			return n
	return 'Unknown'


from math import log

def get_issuer(number):
	length = int(log(number, 10) + 1)
	(first_one, first_two, first_four) = (number // 10 ** (length - 1), number // 10 ** (length - 2), number // 10 ** (length - 4))
	if length == 16:
		if first_one == 4:
			return 'VISA'
		if first_two in range(51, 56):
			return 'Mastercard'
		if first_four == 6011:
			return 'Discover'
	elif length == 15:
		if first_two in (34, 37):
			return 'AMEX'
	elif length == 13:
		if first_one == 4:
			return 'VISA'
	return 'Unknown'


import re
issuers = (('AMEX', '3[47].{13}'), ('Discover', '6011.{12}'), ('Mastercard', '5[1-5].{14}'), ('VISA', '4(...){4,5}'), ('Unknown', '.*'))

def get_issuer(number):
	return next((name for (name, regex) in issuers if re.fullmatch(regex, str(number))))


def get_issuer(number):
	card = str(number)
	ln = len(card)
	return 'AMEX' if card[:2] in ('34', '37') and ln == 15 else 'Discover' if card[:4] == '6011' and ln == 16 else 'Mastercard' if '50' < card[:2] < '56' and ln == 16 else 'VISA' if card[:1] == '4' and ln in (13, 16) else 'Unknown'


def get_issuer(number):
	n = str(number)
	return ['Unknown', 'AMEX', 'Discover', 'Mastercard', 'VISA'][(len(n) == 15 and n[:2] in ['34', '37']) + 2 * (len(n) == 16 and n[:4] == '6011') + 3 * (len(n) == 16 and n[:2] in ['51', '52', '53', '54', '55']) + 4 * (len(n) in [13, 16] and n[0] == '4')]


def get_issuer(number):
	n = str(number)
	if n[0] == '4' and (len(n) == 16 or len(n) == 13):
		return 'VISA'
	if n[0] == '5' and n[1] in '12345' and (len(n) == 16):
		return 'Mastercard'
	if n[0:4] == '6011' and len(n) == 16:
		return 'Discover'
	if n[0] == '3' and n[1] in '47' and (len(n) == 15):
		return 'AMEX'
	return 'Unknown'


def get_issuer(n):
	n = str(n)
	if n[:2] in ['34', '37'] and len(n) == 15:
		return 'AMEX'
	elif n[:4] == '6011' and len(n) == 16:
		return 'Discover'
	elif n[:2] in ['51', '52', '53', '54', '55'] and len(n) == 16:
		return 'Mastercard'
	elif n[0] == '4' and len(n) in [13, 16]:
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(m):
	m = str(m)
	if int(m[0:2]) in (34, 37) and len(m) == 15:
		return 'AMEX'
	elif int(m[0:4]) == 6011 and len(m) == 16:
		return 'Discover'
	elif int(m[0:2]) in range(50, 56) and len(m) == 16:
		return 'Mastercard'
	elif int(m[0]) == 4 and len(m) in (13, 16):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	print(number)
	if len(str(number)) < 13:
		return 'Unknown'
	elif str(number)[0] == '4' and (len(str(number)) == 13 or len(str(number)) == 16):
		return 'VISA'
	elif str(number)[:4] == '6011':
		return 'Discover'
	else:
		return {'34': 'AMEX', '37': 'AMEX', '51': 'Mastercard', '52': 'Mastercard', '53': 'Mastercard', '54': 'Mastercard', '55': 'Mastercard'}.get(str(number)[:2], 'Unknown')


def get_issuer(number):
	card_str = str(number)
	master_card_prefix = list(range(51, 56))
	if card_str[0] == '4':
		if len(card_str) == 13 or len(card_str) == 16:
			return 'VISA'
		else:
			return 'Unknown'
	elif card_str[0:2] == '34' or card_str[0:2] == '37':
		if len(card_str) == 15:
			return 'AMEX'
		else:
			return 'Unknown'
	elif card_str[0:4] == '6011':
		if len(card_str) == 16:
			return 'Discover'
		else:
			return 'Unknown'
	elif int(card_str[0:2]) in master_card_prefix:
		if len(card_str) == 16:
			return 'Mastercard'
		else:
			return 'Unknown'
	else:
		return 'Unknown'


def get_issuer(number):
	number = [int(x) for x in str(number)]
	length = len(number)
	if number[0] == 4 and length == 13 or (number[0] == 4 and length == 16):
		return 'VISA'
	elif number[0] == 3 and number[1] == 4 or ((number[0] == 3 and number[1] == 7) and length == 15):
		return 'AMEX'
	elif number[0] == 5 and (number[1] == 1 or number[1] == 2 or number[1] == 3 or (number[1] == 4) or (number[1] == 5)) and (length == 16):
		return 'Mastercard'
	elif number[0] == 6 and number[1] == 0 and (number[2] == 1) and (number[3] == 1) and (length == 16):
		return 'Discover'
	else:
		return 'Unknown'


def get_issuer(number):
	s = str(number)
	if s.startswith('34') or (s.startswith('37') and len(s) == 15):
		return 'AMEX'
	if s.startswith('6011') and len(s) == 16:
		return 'Discover'
	if int(s[:2]) in range(51, 56) and len(s) == 16:
		return 'Mastercard'
	if s.startswith('4') and (len(s) == 13 or len(s) == 16):
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	if str(number).startswith('34') or (str(number).startswith('37') and len(str(number)) == 15):
		return 'AMEX'
	if str(number).startswith('6011') and len(str(number)) == 16:
		return 'Discover'
	if str(number).startswith('5') and int(str(number)[1]) < 6 and (len(str(number)) == 16):
		return 'Mastercard'
	if str(number).startswith('4') and (len(str(number)) == 13 or len(str(number)) == 16):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	number = str(number)
	if len(number) == 15 and (number.startswith('34') or number.startswith('37')):
		return 'AMEX'
	elif len(number) == 16 and number.startswith('6011'):
		return 'Discover'
	elif len(number) == 16 and (number.startswith('51') or number.startswith('52') or number.startswith('53') or number.startswith('54') or number.startswith('55')):
		return 'Mastercard'
	elif (len(number) == 13 or len(number) == 16) and number.startswith('4'):
		return 'VISA'
	else:
		return 'Unknown'


import re

def get_issuer(number):
	p = re.compile('^(?P<VISA>4(\\d{15}|\\d{12})$)|(?P<AMEX>^(34|37)\\d{13}$)|(?P<Mastercard>5[1-5]\\d{14}$)|(?P<Discover>6011\\d{12}$)').match(str(number))
	return [k for (k, v) in p.groupdict().items() if v][0] if p else 'Unknown'


def get_issuer(n):
	print(str(n))
	if str(n)[0] == '4' and (len(str(n)) == 13 or len(str(n)) == 16):
		return 'VISA'
	if str(n)[0:4] == '6011' and len(str(n)) == 16:
		return 'Discover'
	if str(n)[0] == '5' and str(n)[1] in '12345' and (len(str(n)) == 16):
		return 'Mastercard'
	if str(n)[0:2] == '34' or str(n)[0:2] == '37':
		return 'AMEX'
	else:
		return 'Unknown'


def get_issuer(number):
	lst = list(str(number))
	n_len = len(lst)
	if (lst[0:2] == ['3', '4'] or lst[0:2] == ['3', '7']) and n_len == 15:
		return 'AMEX'
	elif lst[0:4] == ['6', '0', '1', '1'] and n_len == 16:
		return 'Discover'
	elif (lst[0] == '5' and lst[1] in ('1', '2', '3', '4', '5')) and n_len == 16:
		return 'Mastercard'
	elif lst[0] == '4' and (n_len == 13 or n_len == 16):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	if str(number)[0] == '3' and str(number)[1] == '4' or (str(number)[1] == '7' and len(str(number)) == 15):
		return 'AMEX'
	elif len(str(number)) == 16 and str(number)[0:4] == '6011':
		return 'Discover'
	elif len(str(number)) == 16 and str(number)[0] == '5' and (str(number)[1] == '1' or str(number)[1] == '2' or str(number)[1] == '3' or (str(number)[1] == '4') or (str(number)[1] == '5')):
		return 'Mastercard'
	elif (len(str(number)) == 13 or len(str(number)) == 16) and str(number)[0] == '4':
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):

	def helper(n, x):
		return str(n).startswith(x)
	L = len(str(number))
	if L == 15 and (helper(number, '34') or helper(number, '37')):
		return 'AMEX'
	elif L == 16 and helper(number, '6011'):
		return 'Discover'
	elif L == 16 and max([helper(number, str(i)) for i in range(51, 56)]) == 1:
		return 'Mastercard'
	elif (L == 13 or L == 16) and helper(number, '4'):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	strng = str(number)
	if len(strng) == 16:
		if strng[0:4] in ['6011']:
			return 'Discover'
		if strng[0:2] in ['51', '52', '53', '54', '55']:
			return 'Mastercard'
		if strng[0] in ['4']:
			return 'VISA'
	elif len(strng) == 15:
		if strng[0:2] in ['34', '37']:
			return 'AMEX'
	elif len(strng) == 13:
		if strng[0] in ['4']:
			return 'VISA'
	return 'Unknown'


def get_issuer(n):
	n = str(n)
	if (n.startswith('34') or n.startswith('37')) and len(n) == 15:
		return 'AMEX'
	elif n.startswith('6011') and len(n) == 16:
		return 'Discover'
	elif 50 < int(n[:2]) < 56 and len(n) == 16:
		return 'Mastercard'
	elif n.startswith('4') and len(n) in [13, 16]:
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	s = str(number)
	l = len(s)
	if l == 15 and s[:2] in ('34', '37'):
		return 'AMEX'
	if l == 16 and s.startswith('6011'):
		return 'Discover'
	if l == 16 and 51 <= int(s[:2]) <= 55:
		return 'Mastercard'
	if l in (13, 16) and s.startswith('4'):
		return 'VISA'
	return 'Unknown'


def get_issuer(n):
	if str(n)[:2] in ('34', '37') and len(str(n)) == 15:
		return 'AMEX'
	if str(n)[:4] == '6011' and len(str(n)) == 16:
		return 'Discover'
	if int(str(n)[:2]) in range(51, 56) and len(str(n)) == 16:
		return 'Mastercard'
	if str(n)[0] == '4' and len(str(n)) in (13, 16):
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	issuer = {'AMEX': ([34, 37], [15]), 'Discover': ([6011], [16]), 'Mastercard': ([51, 52, 53, 54, 55], [16]), 'VISA': ([4], [13, 16])}
	for i in issuer:
		for j in issuer[i][0]:
			if str(number).startswith(str(j)) and len(str(number)) in issuer[i][1]:
				return i
	return 'Unknown'


import re

def get_issuer(number):
	print(number)
	if re.search('^3(4|7)\\d{13}\\Z', str(number)):
		return 'AMEX'
	if re.search('^6011\\d{12}\\Z', str(number)):
		return 'Discover'
	if re.search('^5[1-5]\\d{14}\\Z', str(number)) != None:
		return 'Mastercard'
	if re.search('^4(\\d{12}|\\d{15})\\Z', str(number)):
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	s = str(number)
	if len(s) == 15 and s[:2] in ['34', '37']:
		return 'AMEX'
	if len(s) == 16:
		if s.startswith('6011'):
			return 'Discover'
		if s[:2] in ['51', '52', '53', '54', '55']:
			return 'Mastercard'
	if len(s) in [13, 16] and s[0] == '4':
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	s = str(number)
	l = len(s)
	return {s[:2] in ('34', '37') and l == 15: 'AMEX', s[:4] == '6011' and l == 16: 'Discover', s[:2] in ('51', '52', '53', '54', '55') and l == 16: 'Mastercard', s[0] == '4' and (l == 13 or l == 16): 'VISA'}.get(True, 'Unknown')


def get_issuer(number):
	n = str(number)
	m = len(n)
	if n[:2] in ('34', '37') and m == 15:
		return 'AMEX'
	if n[:4] in '6011' and m == 16:
		return 'Discover'
	if n[:2] in ('51', '52', '53', '54', '55') and m == 16:
		return 'Mastercard'
	if n[:1] in '4' and m in (13, 16):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	try:
		s = str(number)
		if (s.startswith('34') or s.startswith('37')) and len(s) == 15:
			return 'AMEX'
		if s.startswith('6011') and len(s) == 16:
			return 'Discover'
		if int(s[0]) == 5 and int(s[1]) in [1, 2, 3, 4, 5] and (len(s) == 16):
			return 'Mastercard'
		if s.startswith('4') and (len(s) == 13 or len(s) == 16):
			return 'VISA'
		return 'Unknown'
	except:
		return 'Unknown'


import re

def get_issuer(number):
	snum = str(number)
	if len(snum) == 15 and re.search('^3(4|7)', snum) != None:
		return 'AMEX'
	if len(snum) == 16 and re.search('^6011', snum) != None:
		return 'Discover'
	if len(snum) == 16 and re.search('^5([1-5])', snum) != None:
		return 'Mastercard'
	if (len(snum) == 13 or len(snum) == 16) and re.search('^4', snum) != None:
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	import re
	try:
		groups = re.match('((?:34|37)\\d{13})|(6011\\d{12})|(5[1-5]\\d{14})|(4(?:\\d{12}|\\d{15})$)', str(number)).groups()
	except AttributeError:
		return 'Unknown'
	if groups[0] is not None:
		return 'AMEX'
	elif groups[1] is not None:
		return 'Discover'
	elif groups[2] is not None:
		return 'Mastercard'
	elif groups[3] is not None:
		return 'VISA'


from re import match

def get_issuer(number):
	s = str(number)
	return 'AMEX' if match('^3[47](\\d){13}$', s) else 'Discover' if match('^6011(\\d){12}$', s) else 'Mastercard' if match('^5[1-5](\\d){14}$', s) else 'VISA' if match('^4(\\d){12}$', s) or match('^4(\\d){15}$', s) else 'Unknown'


def get_issuer(n):
	(n, siz) = (str(n), len(str(n)))
	if siz == 15 and n.startswith(('34', '37')):
		return 'AMEX'
	if siz == 16 and n.startswith('6011'):
		return 'Discover'
	if siz == 16 and n.startswith(('51', '52', '53', '54', '55')):
		return 'Mastercard'
	if (siz == 16 or siz == 13) and n.startswith('4'):
		return 'VISA'
	return 'Unknown'


def get_issuer(number):
	if len(str(number)) == 15:
		return 'AMEX' if str(number)[:2] in ['34', '37'] else 'Unknown'
	elif len(str(number)) in [13, 16]:
		if str(number)[:4] == '6011':
			return 'Discover'
		elif str(number)[:2] in list(map(str, range(51, 56))):
			return 'Mastercard'
		elif str(number)[0] == '4':
			return 'VISA'
		else:
			return 'Unknown'
	else:
		return 'Unknown'


def get_issuer(number):
	num = str(number)
	if (num[:2] == '34' or num[:2] == '37') and len(num) == 15:
		return 'AMEX'
	elif num[:4] == '6011' and len(num) == 16:
		return 'Discover'
	elif num[:2] in ['51', '52', '53', '54', '55'] and len(num) == 16:
		return 'Mastercard'
	elif num[:1] == '4' and (len(num) == 16 or len(num) == 13):
		return 'VISA'
	return 'Unknown'


L = {}
for s in ('AMEX_34 37_15', 'Discover_6011_16', 'Mastercard_51 52 53 54 55_16', 'VISA_4_13_16'):
	(a, b, *c) = s.split('_')
	L[a] = (b.split(' '), tuple(map(int, c)))

def get_issuer(n):
	s = str(n)
	for k in L:
		(ps, ls) = L[k]
		if len(s) in ls and any((s.startswith(p) for p in ps)):
			return k
	return 'Unknown'


def get_issuer(number):
	b = list(str(number))
	if len(b) < 13:
		return 'Unknown'
	elif len(b) > 16:
		return 'Unknown'
	elif len(b) == 14:
		return 'Unknown'
	elif b[0] == '3':
		if b[1] == '4' or b[1] == '7':
			if len(b) == 15:
				return 'AMEX'
			elif len(b) == 13:
				return 'Unknown'
		else:
			return 'Unknown'
	elif b[0] == '6':
		if b[1] == '0':
			if b[2] == '1':
				if b[3] == '1':
					if len(b) == 16:
						return 'Discover'
		else:
			return 'Unknown'
	elif b[0] == '5':
		if b[1] == '6':
			return 'Unknown'
		elif b[1] == '1' or b[1] == '2' or b[1] == '3' or (b[1] == '4') or (b[1] == '5'):
			if len(b) == 16:
				return 'Mastercard'
			else:
				return 'Unknown'
	elif b[0] == '4':
		if len(b) == 13:
			return 'VISA'
		elif len(b) == 16:
			return 'VISA'
		else:
			return 'Unknown'
	else:
		return 'Unknown'


def get_issuer(number):
	number = str(number)
	if len(number) == 15 and number[:2] in ('34', '37'):
		return 'AMEX'
	if len(number) == 16 and number[:4] == '6011':
		return 'Discover'
	if len(number) == 16 and '51' <= number[:2] <= '55':
		return 'Mastercard'
	if len(number) in (13, 16) and number[0] == '4':
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	card_types = {'AMEX': {'begin': ('34', '37'), 'num_len': '15'}, 'Discover': {'begin': '6011', 'num_len': '16'}, 'Mastercard': {'begin': ('51', '52', '53', '54', '55'), 'num_len': '16'}, 'VISA': {'begin': '4', 'num_len': ('13', '16')}}
	for (k, v) in card_types.items():
		if str(number).startswith(v['begin']) and str(len(str(number))) in v['num_len']:
			return k
	return 'Unknown'


def get_issuer(number):
	AMEX_FIRST_DIGITS = ('34', '37')
	DISCOVER_FIRST_DIGITS = '6011'
	MASTERCARD_FIRST_DIGITS = ('51', '52', '53', '54', '55')
	VISA_FIRST_DIGITS = '4'
	number = str(number)
	if number.startswith(AMEX_FIRST_DIGITS) and len(number) == 15:
		return 'AMEX'
	elif number.startswith(DISCOVER_FIRST_DIGITS) and len(number) == 16:
		return 'Discover'
	elif number.startswith(MASTERCARD_FIRST_DIGITS) and len(number) == 16:
		return 'Mastercard'
	elif number.startswith(VISA_FIRST_DIGITS) and len(number) in (13, 16):
		return 'VISA'
	else:
		return 'Unknown'


def get_issuer(number):
	card = list((int(x) for x in str(number)))
	if len(card) == 15:
		if card[0] == 3:
			if card[1] == 4 or card[1] == 7:
				return 'AMEX'
		else:
			return 'Unknown'
	elif len(card) == 13:
		if card[0] == 4:
			return 'VISA'
		else:
			return 'Unknown'
	elif len(card) == 16:
		if card[0:4] == [6, 0, 1, 1]:
			return 'Discover'
		elif card[0] == 4:
			return 'VISA'
		elif card[0] == 5:
			if card[1] in range(1, 6):
				return 'Mastercard'
			else:
				return 'Unknown'
		else:
			return 'Unknown'
	else:
		return 'Unknown'


def get_issuer(number):
	n = str(number)
	if n[0:2] == '34' or (n[0:2] == '37' and len(n) == 15):
		return 'AMEX'
	elif n[0] == '4' and (len(n) == 13 or len(n) == 16):
		return 'VISA'
	elif n[0] == '5' and len(n) == 16:
		if 1 <= int(n[1]) <= 5:
			return 'Mastercard'
		else:
			return 'Unknown'
	elif n[0:4] == '6011' and len(n) == 16:
		return 'Discover'
	else:
		return 'Unknown'


def get_issuer(number):
	n = str(number)
	length = len(n)
	if int(n[:2]) in [34, 37] and length == 15:
		return 'AMEX'
	elif n.startswith('6011') and length == 16:
		return 'Discover'
	elif int(n[:2]) in range(51, 56) and length == 16:
		return 'Mastercard'
	elif n[0] == '4' and (length == 13 or length == 16):
		return 'VISA'
	return 'Unknown'