-1
Good afternoon everyone, I have a question about my Python studies.
According to the proposed exercise, I should create a list scheme within a larger list where a name and age will be recorded sequentially. Once that’s done, I should point out who the older person is but I’m having trouble trying to solve it.
dados = list()
listac = list()
maior = list()
cont = 0
while True:
print('_'*15)
dados.append(str(input('Nome: ')))
dados.append((int(input('Idade: '))))
listac.append(dados[:])
dados.clear()
cont += 1
if cont == 3:
break
print()
print(listac)
print()
for a in listac:
print(f'{a[0]} tem {a[1]} anos de idade.')
print(listac)
what is the problem? can you give a brief explanation? what is going wrong? what is your question, specifically?
– Ramon Dias
I can’t pinpoint the age of the older person within this exercise. I tried using max and min, but it doesn’t work.
– Jean Flordemiro
With the code, I can so far create a list to receive names and their ages, and each name and age are divided into lists. Ex: [ [Jean, 27], [Jonas, 25], [Caio, 13]. Three lists within one. What I can do so far is pull the indexes, the names and the ages. Ex: print(listac[0][0] that will return Jean.
– Jean Flordemiro