isalpha() — Python Technical Interview Questions & Answers

isalpha()

isalpha()

  • isalpha is a string helper. You call it on text like "Asha" or "banana". It gives a new string (or a number/True-False). The old string does not change unless you assign the result back.
  • isalpha() — output: True then False.
  • Fresher trap: writing s.isalpha() and expecting s to update. Strings are immutable. Write s = s.isalpha(...) if you need the new value (when it returns a string).

Technical Interview Tip: Call isalpha on one real word and say what prints.

Code Examples for isalpha()

Example

# isalpha()
print("Asha".isalpha())
print("Asha1".isalpha())

isalpha() — output: True then False.

How to Explain isalpha() to an Interviewer

Explain isalpha() as if you are teaching a junior — definition, then one tiny script.

isalpha works on str. isalpha usually returns a new string.

What does the example print, and why?

isalpha() — output: True then False

What mistake do freshers make with isalpha()?

isalpha does not change the original string in place.