Вам предоставлен список номеров.
Код: Выделить всё
nums = [1,35,12,24,31,51,70,100]
количества значений в списке чисел, которые ниже 20.
Я нашел в подсказке следующее решение:
Код: Выделить всё
def count(total):
total = 0
x = 0
sorted_list = sorted(nums)
while x < len(sorted_list):
if sorted_list[x] < 20:
total += 1
x += 1
return total
print(count(total))
Я тоже пытался запустить этот код, и он работает:
Код: Выделить всё
def count(total):
total = 0
x = 0
while x < len(nums):
if nums[x] < 20:
total += 1
x += 1
return total
print(count(total))
Подробнее здесь: https://stackoverflow.com/questions/792 ... al-in-list
Мобильная версия