Bird
0
0

The following code is intended to find the index of 10 in the list data. What is wrong?

medium📝 Analysis Q14 of 15
Intro to Computing - How Files and Folders Organize Data
The following code is intended to find the index of 10 in the list data. What is wrong?
data = [4, 8, 10, 15]
position = data.find(10)
print(position)
AThe list is missing the element 10
BThe list method should be index(), not find()
CThe print statement syntax is incorrect
DThe variable name 'position' is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check method used on list

    Python lists do not have a find() method; they use index() to find element positions.
  2. Step 2: Identify correct method

    Replacing find() with index() fixes the error.
  3. Final Answer:

    The list method should be index(), not find() -> Option B
  4. Quick Check:

    List search method = index() [OK]
Quick Trick: Use index() for lists, find() is for strings [OK]
Common Mistakes:
  • Assuming find() works on lists
  • Thinking element 10 is missing
  • Believing print syntax is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Intro to Computing Quizzes