Please help me w/ this code

from collections import Counter
def hasMultipleDigit(a):

    c = Counter(str(a))
    if any(value > 1 for value in c.values()):
        return False
        return True

def Divide2(a):
    b = str(a)
    TheNumtoDiv1 = str(b[0:1])

    if int(TheNumtoDiv1)%2 == 0:
        return True

def Divide3(a):
    b = str(a)
    TheNumtoDiv = str(b[0:2])
    if int(TheNumtoDiv)%3==0:
        return True
def Divide4(a):
    b = str(a)
    thenum = str(b[0:3])
    if int(thenum)%4==0:
        return True

def Divide6(a):
    b = str(a)
    thenum = str(b[0:5])
    if int(thenum)%6==0:
        return True
def Divide7(a):
    b = str(a)
    thenum = str(b[0:6])
    if int(thenum)%7==0:
        return True

n = 1234567890
lista = [int(x) for x in str(n)]
while n < 9876543210:
    if lista[4] == 5:
        if lista[9] == 0:
            if hasMultipleDigit(n) == False:
                if Divide2(n) == True:
                    if Divide3(n)==True:
                        if Divide4(n) == True:
                            if Divide6(n) == True:
                                if Divide7(n) == True:

    n += 1

Please help me to make this code running easier!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Hello there.

Why not do this:

if lista[4] == 5 and lista[9] == 0 and hasMultipleDigit(n) == False and Divide2(n) == True and Divide3(n)==True and Divide4(n) == True and Divide6(n) == True and Divide7(n) == True:

Hope this helps

I am kind of allergic to and or or inside of if…else… and other loops. I wrote lots of codes based on that but they didn’t have much things to believe in.

Well, what would you like to “run easier” in the code?

I mean, is there any codes or built-in functions to replace some of it?