Trying to calculate a check-digit and add it to the end of generated credit card. So i want to concatenate two integers into a string. Problem is that this chunk of code generates a LIST of numbers rather than a number itself..
checkDigit = 0
while checksum % 10 != 0:
checksum += 1
checkDigit += 1
cc_number = str(cc_number) + str(checkDigit)
return cc_number
So here i'm trying to calculate what number i need to add to checksum in order to produce a credit card which meets Luhn algorithm requirements. I'm expecting to get say number "5", but instead i get a list of 5 elements like "123456". And then it is concatenated to the end of first number... Why is that? I want to get for example: 2222222225 and NOT 222222222123456
Unindent
cc_number = str(cc_number) + str(checkDigit)
. It sounds like you only want to 'append' str(checkDigit) at the end of the loop, once you have determined the correct checkDigit. (I say 'append' because strings are immutable in python.)