PCEP Computer Programming and Python Fundamentals Practice Question
A programmer wants to iterate over a list of strings and print each string in uppercase. Which of the following code snippets will accomplish this?
⚠ Common exam trap
The trap here is that candidates often forget to include parentheses when calling a method (e.g., `item.upper` vs `item.upper()`), or they mistakenly think `upper()` modifies the string in place, leading them to print the original variable instead of the returned value.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
for item in my_list: print(item.upper())
It correctly calls the `upper()` method on each string `item` in the list `my_list` and prints the result. The `upper()` method returns a new string with all characters converted to uppercase, and the `print()` function outputs that value to the console.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
for item in my_list: print(item.upper)
Why it's wrong here
print(item.upper) outputs the bound method object rather than the uppercased string, because the parentheses that invoke the call are absent. The iteration and attribute access are otherwise sound. Adding () would make this the correct snippet; without invocation, no transformation occurs.
- ✗
for item in my_list: item.upper() print(item)
Why it's wrong here
Calling item.upper() returns a new string but discards it, so print outputs the original lowercase value. The method is correct; the missing assignment or inline call is the flaw. This pattern would work if the goal were to mutate a list in place via index assignment, which strings do not support anyway.
- ✗
for i in my_list: print(my_list[i].upper())
Why it's wrong here
Iterating with 'for i in my_list' binds i to each string element, then indexes the list with that string, raising TypeError since list indices must be integers. The uppercase call itself is right. This form would be correct with enumerate() or range(len(my_list)), where i is a numeric index.
- ✓
for item in my_list: print(item.upper())
Why this is correct
Iterating directly over my_list yields each string, and calling .upper() on it returns the uppercase form, which print outputs. This satisfies the requirement to print every string in uppercase without needing index tracking or a separate conversion step.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.