Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
comparison in lists
#1
Hi, i'm a beginner in python and programmation, and i have a doubt about comparison in lists, I have this error

Error:
TypeError: '>' not supported between instances of 'int' and 'list'
but i can try three times after this, so that means it goes into my IF block, right ?
the error is in this line, according to pycharm.
        if lista1[1] > maior:
            maior = lista[1]
the code is written in Portuguese, i hope you can understand.
Thanks

lista = []
lista1 = []
cont = 's'
maior = menor = pessoas = contador = 0

while cont in 'Ss':
    lista1.append(str(input(' NOME : ')))
    lista1.append(int(input(' PESO : ')))
    lista.append(lista1[:])
    pessoas += 1
    contador += 1
    print(lista1[1])  # 38 88 11
    if contador == 1:
        maior = lista1[1]
        menor = lista1[1]
    else:
        if lista1[1] > maior:
            maior = lista[1]
        if lista1[1] < menor:
            menor = lista1[1]
    lista1.clear()

    cont = str(input('Quer continuar ? [S/N]'))

print(f'Foram cadastradas {pessoas} pessoas ')
print(lista)
print(f'o mais pesado pesa {maior} e o mais leve pesa {menor}')
Reply


Messages In This Thread
comparison in lists - by Renatoluz - May-10-2019, 06:06 PM
RE: comparison in lists - by Yoriz - May-10-2019, 06:56 PM
RE: comparison in lists - by woooee - May-10-2019, 10:07 PM
RE: comparison in lists - by Renatoluz - May-11-2019, 12:50 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020