M
M
michadimin2021-07-17 12:26:57
Python
michadimin, 2021-07-17 12:26:57

Why, if I enter 5 or more numbers, can the algorithm calculate the sum?

60f2a2914173d856100931.pngTried 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) 60f2a1f002c1c590828745.png

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

1 answer(s)
S
Sergey Sokolov, 2021-07-17
@sergiks

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

The variable 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 question

Ask a Question

731 491 924 answers to any question