Hi there, I’m in the desert level “the trails”, course python
about collecting mushroom.
I feel a bit confused by the item.type, it seems the clause: if coin.type == “Mushroom” won’t work.
like in the following code, the character will not go search for the mushroom (it works when the if judgement is removed)
The code
while flagViolet:
xViolet = flagViolet.pos.x
yViolet = flagViolet.pos.y
self.move({"x":xViolet, "y":yViolet})
if self.pos.x == xViolet and self.pos.y == yViolet:
self.pickUpFlag(flagViolet)
coins = self.findItems()
coinIndex = 0
while coinIndex < len(coins):
coin = coins[coinIndex]
if coin.type == "mushroom":
x= coin.pos.x
y= coin.pos.y
self.moveXY(x, y)
coinIndex += 1
else:
coinIndex += 1
what is the problem of the if coin.type == "mushroom":clause?