Answer the question
In order to leave comments, you need to log in
Why, if I enter 5 or more numbers, can the algorithm calculate the sum?
Tried to fix it in different ways - all to no avail. I even tracked the array using print() after each interaction with it and, logically, everything should work, but no ...
Moreover, strange errors can also occur during the calculation, for which I don’t even have any guesses why they appear. (see screenshot)
Here is the code - https://pastebin.com/StTLf9tH
Here is the ".ui" file - https://disk.yandex.ru/d/72oYSum_DaLB1g
Answer the question
In order to leave comments, you need to log in
there seems to be an error here:
# https://pastebin.com/StTLf9tH
global i
# ...
for i in range(len(int_from_str_array)):
summ_con = summ_con + int_from_str_array[i]
#print(summ_con)
kol = 0
while i < len(win.lineEdit.text()):
if win.lineEdit.text()[i] == "+":
kol = kol + 1
i += 1
i
continues to be used in the second loop while
, keeping the last value from the previous loopfor..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question