I'm running a population model, and the wrong numbers always come out because I'm setting the variables to new values, but then when I want to use the old variables, the loop automatically updates itself and uses the new ones.
juvenile_population = 10
adult_population = 10
senile_population = 1
juvenile_survival = 1
adult_survival = 1
senile_survival = 0
birth_rate = 2
generations = 5
counter = 0
while counter < generations:
juvenile_population = adult_population * birth_rate
adult_population = juvenile_population * juvenile_survival
senile_population = (adult_population * adult_survival) (senile_population * senile_survival)
total_population = juvenile_population + adult_population + senile_population
print("Juvenile: ",juvenile_population)
print("Adult: ",adult_population)
print("Senile: ",senile_population)
print("Total: ",total_population)
counter += 1
A friend said to set new named variables, but then after one loop, won't you get the same problem again? I want the variables to update, but only after they've been printed, if that makes sense. Any suggestions?