Contact: aviboots(AT)netvision.net.il
39,950 questions
51,892 answers
573 users
def binary_to_decimal(s): dec = 0 j = 0 for i in range(len(s) - 1, -1, -1): # range (start, stop[, step]) if (s[i] == '1'): dec += pow(2, j) j += 1 return dec; s = "10101011"; print(binary_to_decimal(s)) ''' run: 171 '''