+ 2
Can any explain this pls
X = 0 Z = [1,2,3,4,5] For I in z : X = x + I If not (x<9): Result = x - I Print(result) Break
6 Answers
+ 3
Solo ,
we can not just take a single test case and assume that everything will be correct. this is careless.
if the list has other values, it matters. e.g. [1,2,3,1,1,1,1]
+ 2
The sum of the values ââof z is assigned to x until it becomes greater than 9, then the condition will work and subtract the last value from x, print the result and stop the loop.
0+1+2+3+4 < 9 â> false
not false â> true
result = 10 - 4
+ 2
Solo ,
shouldn't it be:
"the sum of the values of z is assigned to x until it becomes *GREATER OR EQUAL* than 9..."
+ 1
Lothar , yes but in this case x will never be equal to 9 đ
+ 1
Lothar , no buddy, we are looking at a specific example, not some abstract statements.
0
Recheck your code there is lot of error like capital letter s "F" for ,for loop and variable. correct this small error.