Implement the Luhn Algorithm - Implement the Luhn Algorithm

Tell us what’s happening:

My algorithm works just fine when I give it a number, but step 6 keeps failing and I don’t know why!

Your code so far

def verify_card_number(string):
    number = ""
    for c in string:
        if c.isdigit(): 
            number += c

    try:
        number = int(number)
    except:
        return "INVALID!"
    summ = 0
    while number > 0:
        summ += number % 10
        number = int(number / 10)
        if number == 0:
            break
        double = (number % 10) * 2
        if double >= 10:
            double = double - 9  
        summ += double
        number = int(number / 10)
    
    if summ % 10 == 0:
        return "VALID!"
    else:
        return "INVALID!"


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36

Challenge Information:

Implement the Luhn Algorithm - Implement the Luhn Algorithm

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-luhn-algorithm/68507cadbf36aa089a84ce2d.md at main · freeCodeCamp/freeCodeCamp · GitHub

This test should return valid:

print(verify_card_number('6011000990139424173'))

Thank you, the problem was just I am using float divison rather than floor division that couldn’t handle that long number.