Bird
0
0

Given the code below, what will be the output?

medium📝 Predict Output Q13 of 15
Agentic AI - Agent Safety and Guardrails
Given the code below, what will be the output?
def sanitize_input(text):
    return text.strip().lower()

user_input = '  Hello World!  '
cleaned = sanitize_input(user_input)
print(cleaned)
A Hello World!
B!dlroW olleH
CHELLO WORLD!
Dhello world!
Step-by-Step Solution
Solution:
  1. Step 1: Understand strip()

    The strip() method removes spaces from the start and end of the string.
  2. Step 2: Understand lower()

    The lower() method converts all letters to lowercase.
  3. Final Answer:

    hello world! -> Option D
  4. Quick Check:

    strip + lower = 'hello world!' [OK]
Quick Trick: strip removes spaces, lower makes all letters small [OK]
Common Mistakes:
  • Ignoring strip() effect on spaces
  • Confusing lower() with upper()
  • Expecting original casing in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes