Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

How do I to prioritize gold coins, then silver and copper in their respective order?


In the level “Sarven Treasure”, I try to find the Nearest gold coin first, then silver, then copper last: but every code I try doesn’t seem to work! Please help ASAP!


All coins have a value, with gold being worth 3, silver worth 2, and bronze 1. To find them, you can use something like this:

coins = [c for c in self.findItems() if c.value == x]

Where x is the value that you are searching for.


Oh, I’m a JavaScript user…


Well, in that case, use this:

var coins = this.findItems();
var coinList = []; 
var coinIndex = 0;
var coinValue = "Whatever value you want";
while (coinIndex < coins.length) {
    var coin = coins[coinIndex];
    if (coin.value === coinValue) {


Wow, thanks! I’ll try it out and see how it works. I’ll let you know of the results…