Я пытаюсь использовать метод понимания списка, чтобы найти в моем списке элементы, размер которых превышает одну из моих переменных.
Однако я получаю это сообщение об ошибке:
TypeError: '>' not supported between instances of 'list' and 'float'
Iне знаю, как обойти это.Какие-нибудь советы?Вот моя программа:
def read_points():
global alfa
alfa = []
alfa.append([])
alfa.append([])
a = 0
b = 0
a = float(a)
b = float(b)
print("Input the points, one per line as x,y.\nStop by entering an empty line.")
while a == 0:
start = input()
if start == '':
a = a + 1
if b == 0:
print("You did not input any points.")
else:
alfa[0].append(int(start.split(",")[0]))
alfa[1].append(int(start.split(",")[1]))
b = b + 1
else:
print(alfa)
def calculate_midpoint():
midx = sum(alfa[0]) / len(alfa[0])
global midy
midy = sum(alfa[1]) / len(alfa[1])
print("The midpoint is (",midx,",",midy,").")
def above_point():
larger = [i for i in alfa if i > midy] ### PROBLEM IS HERE :) ###
number_above = len(larger)
print("The number of points above the midpoint is", number_above)
def main():
read_points()
calculate_midpoint()
above_point()
main()