What's wrong with the code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's wrong with the code?

#Enter: 1010101100 sys_znach = input() list_znach = list(sys_znach) len_znach = len(list_znach) - 1 my_array = [] count = len_znach i = 0 while i != len_znach: while count != 0: sys_x2 = int(list_znach[i])*(2**count) my_array.append(sys_x2) count -= 1 i += 1 print("Des system:",int(sum(my_array))) It must convert the id of the binary system to decimal.

11th Oct 2017, 10:45 PM
Vadim
Vadim - avatar
2 Answers
0
If you try in English maybe you could get more help
11th Oct 2017, 11:53 PM
Daniel
Daniel - avatar
- 1
While I don't know py, your inner loop only executes once as count becomes 0 during it's first pass and never changes.
12th Oct 2017, 8:04 AM
John Wells
John Wells - avatar