String Methods in Python

Cadenas (Strings)Formato de cadenas

Strings come with many built-in methods that help you manipulate and check text. These methods return new strings – they don't change the original (strings are immutable).

We'll go through the most common ones with explanations and examples you can run right away.

Changing Case

These methods convert the string to uppercase, lowercase, title case (first letter of each word capitalized), or capitalize the first letter.

Trimming Whitespace

strip() removes whitespace from both ends, lstrip() from the left, and rstrip() from the right. This is useful when cleaning user input.

Replacing Text

replace() substitutes text. By default it replaces all occurrences, but you can limit the number of replacements.

Splitting and Joining

split() turns a string into a list by separating at a delimiter (default is whitespace). join() does the opposite – combines a list into a string using a separator.

Checking Content

These methods return True or False to check if a string starts/ends with something or contains only certain characters.

Finding Positions

find() returns the index of the first occurrence or -1 if not found. index() does the same but raises ValueError if not found.

Quick Quiz

Hemos revisado y comprobado los materiales, pero aún pueden existir errores. El contenido se ofrece únicamente con fines educativos, así que úsalo bajo tu propia responsabilidad y verifica con otras fuentes si es necesario.

✨ Pregunta a Lara — tu compañera de estudio con IA

Desbloquea soporte de aprendizaje personalizado. Lara puede explicar lecciones, resumir temas y responder tus preguntas — disponible desde el plan Go y superiores.


Lara te ayuda a aprender más rápido — exclusivo para los miembros ReadyTools Go, Plus y Max.

Sigue Tu Progreso 🚀

Aprende más fácilmente siguiendo tu progreso completamente gratis.