Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Coding Quiz - Finding Rotten Apples

In this coding quiz, you will write a function to find rotten apples in a basket.

You will receive a list indicating the state of apples and your task is to return a list of indices where the apples are rotten.

The apple basket is represented by a list of integers, where rotten apples are denoted as 0, and fresh apples are indicated by 1.


Write your code
def solution(apples):
# Write your code here
return



Constraints

  • The input list will only contain elements 0 or 1.

  • The list will contain at least one element.




Example of inputs and outputs

  • Input: [1, 0, 1, 0, 1]

  • Output: [1, 3]


  • Input: [1, 0, 0, 1]

  • Output: [1, 2]

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.