Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit card numbers are 16 numbers long with spaces every four numbers (represented by s below).Order of the numbers means something specific as shown below.The

Credit card numbers are 16 numbers long with spaces every four numbers (represented by s below).Order of the numbers means something specific as shown below.The first number represents what type of card it is:4 is Visa, 5 is Discovery Card, 6 is Master Card. Routing number and credit limit is embedded.For example, the card below is a Visa with routing number 567891 and the credit limit is $3500.00.The credit limit is in hundreds of dollars.

4234s5678s9123s5362

Type

Routing Number

Credit Limit

I need a function break_up that accepts a string that represents a credit card number and returns the type of card, the routing number, and the credit limit on the card.The function must use slicing and cannot use split.

The main function will let a user enter a string representing a credit card number (including spaces) and then pass this string to function break_up.Sample input would be (notice the spaces every four characters:

Enter credit card number: 4234 5678 9123 5362

Function main will format and print the type of card, the routing number and the credit limit as follows.No extra spaces.

Visa

Routing Number:567891

Credit Limit: $3500.00

Python allows you to return multiple values from a function. For example,

def my_function(value):

x = value

y = 2

return x,y

def main():

num1, num2 = my_function(6)

print(num1)

print(num2)

You can use this idea for the break_up function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

Students also viewed these Programming questions