(Disclaimer: I'm very new to coding so sorry if this is a ridiculously stupid question!)
I'm currently trying to change the Python code below so that instead of needing 4 obstacles to not be false in order to call the obstacle_detection method (which is defined earlier in the program), it will call the method if any number of obstacles are not False.
if obstacle is not False and obstacle2 is not False and obstacle3 is not False and obstacle4 is not False:
test = obstacle_detection(obstacle, pos)
test2 = obstacle_detection(obstacle2, pos)
test3 = obstacle_detection(obstacle3, pos)
test4 = obstacle_detection(obstacle4, pos)
else:
test = 0
test2 = 0
test3 = 0
test4 = 0
I the tried changing it to something like below but I get the error of "iteration over non sequence" (and I wouldn't be surprised if this is completely the wrong idea):
if any(obstacle) is not False:
for i in obstacle:
test = obstacle_detection(obstacle, pos)
else:
test = 0
Aucun commentaire:
Enregistrer un commentaire