Answer the question
In order to leave comments, you need to log in
Using Python list length?
When writing the code, the task was set to indicate in the number of repetitions of the cycle - the number of elements of the list (The user fills in the list himself) I
enclose the code:
def min2(*a):
k = a[0]
kk = 1
kilkist = len(a)
while kilkist != 0:
if k < a[kk]:
k = a[kk]
kk = kk + 1
kilkist = kilkist - 1
else:
kk = kk + 1
kilkist = kilkist - 1
return k
print(min2(Тут идут рандомные числа))
Answer the question
In order to leave comments, you need to log in
Since in python indexes start from zero, and you iterate from the first, then at the end of the loop the counter will exceed the maximum index and there will be an error.
In addition, in the current form, this is not min, but max.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question