line number 12: you assign 0 to the variable
line number 13: the for loop assign to
line number 14: you adding one to the sum_of_numbers. Do you want to calculate 1+2+3+4+5.. or just the number of values?
line number 15: dedent this line and you get the result after the loop is done. Otherwise you get a result for each iteration.
In line 9, 10 and 13 you are converting the input over and over to an int. One time is enough.
You can reassign the integer to the variable and reuse it.
In line 4 and 5 you're converting the
Line 1: statistis is currently not used in this snippet. Don't import it, when you don't using it. Linters will complain about this.
The code is nested to deep. You should split it up as functions.
One function for
Then each function does only one thing. Handling input data together with calculations makes the code to complex.
The usage can look like this:
The
counter
. You don't need to pre-assign a variable, which is used in a for loop.line number 13: the for loop assign to
counter
. You should rename this variable.line number 14: you adding one to the sum_of_numbers. Do you want to calculate 1+2+3+4+5.. or just the number of values?
line number 15: dedent this line and you get the result after the loop is done. Otherwise you get a result for each iteration.
In line 9, 10 and 13 you are converting the input over and over to an int. One time is enough.
You can reassign the integer to the variable and reuse it.
In line 4 and 5 you're converting the
input
to a str
. The input
function always returns a str
.Line 1: statistis is currently not used in this snippet. Don't import it, when you don't using it. Linters will complain about this.
The code is nested to deep. You should split it up as functions.
One function for
input
x and y and the convert to int
, and one function to do the logic.Then each function does only one thing. Handling input data together with calculations makes the code to complex.
The usage can look like this:
def input_range(): pass def make_sum(x, y): pass x, y = input_range() make_sum(x, y)By the way, if you only want to know the len of a list, tuple or other container objects, use
len
.The
range
function is very special and supports also the len
function.print(len(range(1, 11)))
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!