I am making a python program that should contain some information about lists, and they perform mathematical operations on them. Here is an example of my code:
VCentral = [] Atlantico=[] Pacifico=[] Norte=[] Sur=[] LVC=0 LA=0 LP=0 LN=0 LS=0 LTotal=0 def RegTemp(regcode): global LVC global LA global LP global LN global LS global LTotal registro=[] temp = int(input("Digite la temperatura: ")) fecha=input("Digite la fecha: ") registro.extend((temp,fecha)) if regcode==1: VCentral.extend(registro) LVC+=1 LTotal+=1 if regcode==2: Atlantico.extend(registro) LA+=1 LTotal+=1 if regcode==3: Pacifico.extend(registro) LP+=1 LTotal+=1 if regcode==4: Norte.extend(registro) LN+=1 LTotal+=1 if regcode==5: Sur.extend(registro) LS+=1 LTotal+=1
And then I need to compare its meanings with something else. here is another example of the function I'm trying to implement:
def Mayor(regcode): if regcode==1: may=0 for i in VCentral: if i[0]>may: may=i[0] return may if regcode==2: may=0 for i in Atlantico: if i[0]>may: may=i[0] return may if regcode==3: may=0 for i in Pacifico: if i[0]>may: may=i[0] return may if regcode==4: may=0 for i in Norte: if i[0]>may: may=i[0] return may if regcode==5: may=0 for i in Sur: if i[0]>may: may=i[0] return may
If you could tell me why this is causing me a mistake, I would appreciate it.
EDIT:
Traceback (most recent call last): File "D:/tarea2.py", line 212, in <module> Menu() File "D:/tarea2.py", line 199, in Menu print(EstadisticaZona(regcode)) File "D:/tarea2.py", line 165, in EstadisticaZona print("Temperatura mayor: ",Mayor(2)) File "D:/tarea2.py", line 102, in Mayor if i[0]>may: TypeError: 'int' object is not subscriptable
source share