Mistři v programování na #hovnokod

def validate(timeinstr):
    if timeinstr:
        timeinstr = timeinstr.split(':')
        if len(timeinstr) != 2:
            return 0, 0
        hour = int(timeinstr[0])
        minute = int(timeinstr[1])
        if (hour < 0) or (hour > 23):
            return 0, 0
        if (minute < 0) or (minute > 59):
            return 0, 0
        return hour, minute
    return 0, 0

Anonymous,

def IsEven(num):
    i =  2
    while i < 2147483647:
        if i == num:
            print "The number is even"
            i += 2
            return
    print "The number is false"
    return

Anonymous,


Anonymous,

když if x in y je moc mainstream

def contains(list, char):
    try:
        index = list.index(char)
        return True
    except:
        return False

Anonymous,

Jak dostat seznam náhodných čísel v rozmezí < -pocet_stran; pocet_stran >

def generuj(self, cislo: int):
        return [(int(random.random() * 100 % self.pocet_stran) + 1) * (int(random.random() * 10 % 2) * -2 + 1) for x in range(cislo)]

Anonymous,