numbers = 1,-8,-4,5,12 summa = 0 for num in numbers: if num < 0: summa += num print(summa) - oneCan. It is enough to understand what a cycle is. - Vladimir Martyanov
- it only occurred to me to create another cycle that would output the minimum value of all, is there an easier option? - agre
- In the cycle, determine the amount, and after its completion output the result. Read about the cycles. - justyx
- numbers = 1, -8, -4,5,12 summa = 0 result = 0 for num in numbers: if num <0: summa + = num result = summa print (result) - agre
- thanks for the instruction) - agre
|
1 answer
numbers = 1,-8,-4,5,12 summa = 0 result = 0 for num in numbers: if num < 0: summa += num result = summa print(result) - Why do you use
result = summa? What result do you want to achieve? What do you think happens ifprint(summa)is added after the loop? - jfs - don't blame me, i'm just learning, so i make such elementary mistakes ( - agre
- It's not scary, everyone starts somewhere. Edit your answer if you know how to improve it. Describe in words how you understand the solution. - jfs
|