Credit Card Number Extraction

Problem Statement

The company ABC is into banking services. The company has this requirement where it receives a request string, and we need to extract the credit card number from the request string.

Credit card number is a 16 digit number.

Now, the first character in the request string is a flag value that determines the position of the credit card number in the string. If the first character is `A`, then the credit card number starts from 12th character in the request string. Or, if the first character is `B`, then the credit card number starts from 14th character in the request string. Or, if the first character does not match the previous two cases, then return an empty string for the credit card number.

Input

The first line of input is a string: `request`, representing the request string to the company ABC.

Output

Print the extracted credit card number.

As is

The boilerplate code is already there to read the inputs from user, in the `main()` function, and to print the value returned by the `extractCreditCardNumber()` function. Do not edit this code.

To do ✍

`extractCreditCardNumber()` has one parameter: `request`. Write code inside the function body to extract the credit card number, and return the same.

Example 1

Test input

``A12745122214606123456780000F8BCA47852``

Test output

``4606123456780000``

Explanation

Since the first character is `A`, credit card number starts from 12th character `index=11` in the request string.

Example 2

Test input

``B1800745122214606123456781200F8BCA47852FEC029AB85``

Test output

``4606123456781200``

Explanation

Since the first character is `B`, credit card number starts from 14th character `index=13` in the request string.

Example 3

Test input

``81800745122214606123456780000F8BCA47852FEC029AB85``

Test output

Explanation

Since the first character is neither `A` nor `B`, the resulting credit card number is an empty string.

Python Program

``````# Complete the following function
def extractCreditCardNumber(request):

# Boilerplate code - Do not edit the following
def main():
request = input()
print(extractCreditCardNumber(request))

if __name__ == "__main__":
main()``````

Testcase 1

``A12005122214606123456781234F8BCA47852``
``4606123456781234``

Testcase 2

``B0012005122214616123456781234F8BCA47852``
``4616123456781234``

Testcase 3

``70012005122214616123456781234F8BCA47852``
``````# Complete the following function
def extractCreditCardNumber(request):
credit_card_number_length = 16
if request[0] == 'A':
return request[11 : 11+credit_card_number_length]
elif request[0] == 'B':
return request[13 : 13+credit_card_number_length]
else:
return ""

# Boilerplate code - Do not edit the following
def main():
request = input()
print(extractCreditCardNumber(request))

if __name__ == "__main__":
main()``````