Question
Can someone help me to correct this code. The problem asks us to: Credit card numbers are 16 numbers long with spaces every four numbers
Can someone help me to correct this code. The problem asks us to:
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.
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
The thing is I wrote the program this way:
def break_up(credit_card):
cc = int(credit_card[0:1])
if cc == 4:
print( "Visa")
elif cc == 5:
print( "Discovery")
elif cc == 6:
print("Master card")
rout = credit_card[5:12]
credit_limit = credit_card[13:16]
return cc,rout,credit_limit
def main():
credit_card = input("Enter credit card number: " )
cc,rout,credit_limit = break_up(credit_card)
print("Routing number: " , rout)
print("Credit limit: $", credit_limit)
main()
and I've got the output as follow:
Enter credit card number: 4234 5678 9123 5362
Visa
Routing number: 5678 91
Credit limit: $ 3 5
Can please help me to solve for this in order my output match the same output the problem asks for.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To fix the issue with your code and ensure that the output matches the desired format you need to ad...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started