Can someone explain to me the following expression: variable1=() variable2=0 ......adding nubers in that tuple... and then for x in (variable1): variable2=variable2+x where we basically add all the numbers in that tuple. What allows us to formulate for... expression in this way and how do we explain it in detail?
the last line of the code coud be like "variable2 += x", and you don't really need those parens around variable1 in for.. statement.
I don't need the parents because I have already appointed variable1 as a name for the tuple is that correct?
yes, you've already set vaalue of variable1 as tuple. The for.. loop iterates over each element in that tuple, and on each iteration (step) of this loop, value of the next element of tuple is assigned to x, which is then added to variable2
Join our real-time social learning platform and learn together with your friends!