Bird
0
0

Given text = ' Python 3.12 ', which code removes spaces only from the right side?

hard📝 Application Q9 of 15
Python - Data Types as Values
Given text = ' Python 3.12 ', which code removes spaces only from the right side?
Atext.lstrip()
Btext.remove()
Ctext.strip()
Dtext.rstrip()
Step-by-Step Solution
Solution:
  1. Step 1: Know the difference between strip methods

    rstrip() removes spaces on the right, lstrip() on the left, and strip() on both sides.
  2. Step 2: Identify the correct method for right side only

    To remove spaces only on the right, use rstrip().
  3. Final Answer:

    text.rstrip() -> Option D
  4. Quick Check:

    rstrip() removes trailing spaces [OK]
Quick Trick: Use rstrip() to remove right-side spaces [OK]
Common Mistakes:
MISTAKES
  • Using strip() removes both sides
  • Using lstrip() removes left side
  • Using non-existent remove() method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes