Write a subroutine in Python called checkTreasure that will count the number of times the string "Gold" appears on an adventure map.
The subroutine should:
islandMap as a parameter"Gold" appears in the islandMap array"Jackpot" if there are exactly five "Gold" items in the array"Gold" items if there are fewer than five.You must write your own counting routine utilizing nested loops and not use any built-in count functions or methods (such as .count()) that might be available in Python.
You should use indentation as appropriate, meaningful variable name(s), and Python syntax in your answer.
| 0 | 1 | 2 | |
|---|---|---|---|
| 0 | Sand | Gold | Sand |
| 1 | Gold | Forest | Gold |
| 2 | Castle | Gold | Gold |
131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.