fork download
  1. def na10(dana):
  2. pom = 0
  3. for i in range(len(dana)):
  4. x = int(dana[- i - 1])
  5. pom = pom + x * 2 ** i
  6. return pom
  7. print (na10("101010"))
  8. print (na10("110101"))
Success #stdin #stdout 0.05s 9640KB
stdin
Standard input is empty
stdout
42
53