I appear to be having this issue in my code and am unable to find a solution so I would be grateful if somebody could please have a look at lines 34,35 and 36 of my code to try and help me remove the required information from the array. (btw I apologise for the comment and general messiness within my code and the fact that it displayed n an external website but I was having issues with formatting on stack overflow)
thanks from Michael Roberts
print(" "*20,"Welcome to the greenfly population model") #printing intro
##########################declaing default variables#########################
generation_input = 10 #default number of generations
birthrate = 2 #default birthrate
juv = 10 #default number of juveniles
adult = 10 #default number of adults
senile = 10 #default number of seniles
population=[] # creating an empty list
population.append([juv,adult,senile]) #adding the default population values to the list
jsrate = 1 #default juvenile survival rate
asrate = 1 #default adult survival rate
ssrate = 0 #default senile survival rate
######################setting generation 0 values###################
def g0set():
global generation_input,birthrate,jsrate,asrate,ssrate #declaring the variables globally
generation_input = int(input("input number of generations for the model to run for:"))
birthrate = float(input("input birthrate of model:"))
juv = int(input("input number of juveniles in the model:"))
adult = int(input("input number of adults in the model:"))
senile = int(input("input number of seniles in the model:"))
population.append([juv,senile,adult]) # adding the new population values into the list
jsrate = float(input("input the juvenile survival rate of the model:"))
asrate = float(input("input the adult survival rate of the model:"))
ssrate = float(input("input the senile survival rate of the model:"))
main_menu()
#####################displaying generation 0 values#################
def g0display():
print("the model will run for ",generation_input," generations")
print("the birthrate of the model is ", birthrate )
print("the number of juveniles in the population model is ",population[0])
print("the number of adults in the population model is ",population[1])
print("the number of seniles in the population model is ",population[2])
print("the juvenile survival rate is ",jsrate)
print("the adult survival rate is ",asrate)
print("the senile survival rate is ",ssrate)
main_menu()
def run_program():
global juv,adult,senile,generation_input,birthrate,jsrate,asrate,ssrate
for i in range (0,generation_input): #looping round until it meets the required number of generations
print (i+1) #printing which generation the loop is on(+1 as i starts from 0)
print (population) #printing the array on which the population is stored
juv1 = juv #storing the previous juvenile values
adult1 = adult #storing the previous adult values
senile1 = senile #storing the previous senile values
juv= adult * birthrate #applying the birthrate to the adults to get the next generation of juveniles
adult=juv1 #the previous generation's juveniles become adults
senile=adult1 #the previous generation's adults become seniles
juv1 = juv * jsrate #applying the juvenile survival rates with the next generation of juveniles to get the final number of next generation juveniles
adult1 = adult * asrate #applying the juvenile survival rates with the next generation of adults to get the final number of next generation adults
senile1 = senile * ssrate #applying the juvenile survival rates with the next generation of seniles to get the final number of next generation seniles
population.append([juv1,adult1,senile1]) #adding the final values of the next generation to the population array
juv=juv1 #setting the number of juveniles equal to that of the next generation
adult=adult1 #setting the number of adults equal to that of the next generation
senile=senile1 #setting the number of seniles equal to that of the next generation
main_menu() #returning to the menu after the program is finished
##################running the main menu#################
def main_menu():
print("-"*35,"main menu","-"*34)
print("input 1 to set generation 0 values") #printing possible options for the program
print("input 2 to display generation 0 values") #printing possible options for the program
print("input 3 to run the population model") #printing possible options for the program
choice = int(input())
if choice == 1:
g0set()
elif choice == 2:
g0display()
elif choice == 3:
run_program()
else:
print("incorrect value entered")
main_menu()
main_menu()