Ad
  • Custom User Avatar

    Just as a variant, you don't need the str(binaryNum) and the if statement

    Instead you can do:

    for num in binaryNum:
    total += int(num)

    considering a binmary number is only 0s and 1s if its a 0 it will add 0 so you can avoid the if statement