Ad
  • Custom User Avatar

    Enumerate also automatically iterates through each of the digits, so you don't need to cast the number to a string, and loop through each letter (like I did lol).

    I did:

    str_number = str(number)
    digit_list = []
    for digit in range(0, len(str_number)):
    digit_list.append(int(str_number[digit]))

    and then enumerated through that digit_list, but the "enumerate(str(n))" in

    for i, c in enumerate(str(n)):

    gives you access to each digit in the number as a string in a much more elegant way.