Good friends, Greetings. The fact is that I am starting in the prog. And testing I found something curious. First look at the code and then the doubt. Thanks in advance
def body():
print(temps)
if __name__ == '__main__':
temps=list()
for i in range(0,7):
if i==0:
datoIngresado=int(input("Ingrese la primera temperatura: "))
temps.append(datoIngresado)
elif i==1:
datoIngresado=int(input("Ingrese la segunda temperatura: "))
temps.append(datoIngresado)
elif i==2:
datoIngresado=int(input("Ingrese la tercera temperatura: "))
temps.append(datoIngresado)
elif i==3:
datoIngresado=int(input("Ingrese la cuarta temperatura: "))
temps.append(datoIngresado)
elif i==4:
datoIngresado=int(input("Ingrese la quinta temperatura: "))
temps.append(datoIngresado)
elif i==5:
datoIngresado=int(input("Ingrese la sexta temperatura: "))
temps.append(datoIngresado)
elif i==6:
datoIngresado=int(input("Ingrese la septima temperatura: "))
temps.append(datoIngresado)
body()
The fact is that I want to make a for loop to request 7 data equivalent to 7 days a week. But as you can see, I have to use 7 structures if comparing them with the variable i of my for cycle. I do this to have to show on screen a different string from the others. That is, pass "enter the first data" and so for the second input "Enter the second data." Where does my doubt come from? Well I try to make a for cycle in which each time it is executed I change in that word (that if first, second and so on, advance the for loop) without having to use so many if structures. Is it possible?