Rich Forager Help

I am having trouble with the level “Rich Forager” here is my code so far (Python)

loop:
flag = self.findFlag()
enemy = self.findNearestEnemy()
item = self.findNearestItem()

if flag:
self.pickUpFlag(flag)

elif enemy:
self.attack(enemy)

elif item:
self.findNearestItem()

Okay, well, what, exactly, is your problem?

Please format your code properly

Read the FAQ!!!

Formatting the code, and letting us know what the issue is that you are seeing would be really good. You may also want to look at moving your character to the item, so it picks it up.

Well guess wut I FAILED

Larkin, this information is not helping, so if you would please be more specific on what you need help with?

Sorry its been a while since i was on but my character doesnt do any thing but attack enemies i try to make him follow the flags and find the coins but still he does nothing, here is my code.

(Python)

loop:
flag = self.findFlag()
enemy = self.findNearest(self.findEnemies())
item = self.findNearest(self.findItems())

if flag:
self.pickUpFlag(flag)

elif enemy:
self.attack(enemy)


elif item:
self.findNearest(self.findItems())

Hello, Larkin. As Feinty and Matt said, please properly format your code.

First things first:
#Whitespace saves lives!

In Python, indentations are important to the running of your program. Put them in, and see whether your hero still has problems.