Create a program using an array, a for loop, and an if statement that checks a group of 5 kids to see whether they have gloves.
- Assume each child has a number representing how many gloves they have.
- Print the indexes of the kids who have enough gloves (at least 2 gloves).
Create a Python program that checks whether kids in a group have enough gloves.
Task description:
- Create a list (array) with 5 numbers.
- Each number represents how many gloves one child has.
- Example:
gloves = [2, 1, 0, 3, 2]
- Use a
for loop to go through the list.
- You should loop through the list using the index of each child.
- Use an
if statement to check whether a child has at least 2 gloves.
- If the condition is true, print the index of that child.
- The index represents the child’s position in the list (starting from 0).
Expected result:
- The program should output the indexes of all children who have 2 or more gloves.
Important notes:
- Use only concepts you have learned so far: lists,
for loops, and if statements.
- Do not use advanced Python features.