So, I made that code that simulates reproduction:
try:
def del1stOccof(string, inList):
inList=list(inList)
elInLst=1
for lElt in inList:
if lElt==string:
del inList[elInLst]
return inList
import random as defi
feedingPlacesNum=int(input("How many food pairs do you want? "))
doveBlobNum=int(input("How many dove blobs do you want? "))
hawkBlobNum=int(input("How many hawk blobs do you want? "))
blobList=[]
repeatsProgram=0
for addingDoves in range(doveBlobNum):
blobList.append("dove")
for addingHawks in range(hawkBlobNum):
blobList.append("hawk")
for i in range(336):
repeatsProgram=repeatsProgram+1
defi.shuffle(blobList)
deleteBlobList=[]
print(f"The number of dove blobs is: {blobList.count("dove")}")
print(f"The number of hawk blobs is: {blobList.count("hawk")}")
fPList=[]
for addingPlacesToFeedingPlacesList in range(feedingPlacesNum*2):
fPList.append("empty")
elementInBlobList=0
for element in blobList:
isBlobNotIn=fPList.count("empty")>0 #We count the number of empty feeding places, and if it's bigger than 0, we allow the blob to enter.
if not isBlobNotIn:
deleteBlobList.append(elementInBlobList)
while isBlobNotIn:
sendBlobTo=2*defi.randint(0,99)
if fPList[sendBlobTo]=="empty":
fPList[sendBlobTo]=element
isBlobNotIn=False
elif fPList[sendBlobTo+1]=="empty":
fPList[sendBlobTo+1]=element
isBlobNotIn=False
elementInBlobList=elementInBlobList+1
for cFPlList in range(int(len(fPList)/2)):
if fPList[cFPlList*2]=="dove" and fPList[cFPlList*2+1]=="dove":
pass
elif fPList[cFPlList*2]=="empty" and fPList[cFPlList*2+1]=="empty":
pass
elif fPList[cFPlList*2]=="dove" and fPList[cFPlList*2+1]=="empty" or fPList[cFPlList*2]=="empty" and fPList[cFPlList*2+1]=="dove":
blobList.append("dove")
elif fPList[cFPlList*2]=="empty" and fPList[cFPlList*2+1]=="hawk" or fPList[cFPlList*2+1]=="empty" and fPList[cFPlList*2]=="hawk":
blobList.append("hawk")
elif fPList[cFPlList*2]=="hawk" and fPList[cFPlList*2+1]=="hawk":
deleteBlobList.append("hawk")
deleteBlobList.append("hawk")
elif fPList[cFPlList*2]=="hawk" and fPList[cFPlList*2+1]=="dove" or fPList[cFPlList*2]=="dove" and fPList[cFPlList*2+1]=="hawk":
if defi.randint(0,1)==0:
deleteBlobList.append("dove")
if defi.randint(0,1)==1:
blobList.append("hawk")
print(f"This is the {repeatsProgram}. generation.")
for deletingUnfedBlobs in deleteBlobList:
blobList=del1stOccof(deletingUnfedBlobs,blobList)
except KeyboardInterrupt:
print("Interrupt: You interrupted the program via Ctrl+C.")```
and it gives the error:
Traceback (most recent call last):
File “c:UsersMarjanaDesktopPythonblobSim.py”, line 62, in
blobList=del1stOccof(deletingUnfedBlobs,blobList)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:UsersMarjanaDesktopPythonblobSim.py”, line 4, in del1stOccof
inList=list(inList)
^^^^^^^^^^^^
TypeError: ‘NoneType’ object is not iterable
anyone know what to do?
I actually didn't do anything because I didn't know what's happening.
AlphaOmega is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.