Python icon indicating copy to clipboard operation
Python copied to clipboard

Improve capitalize(): add Unicode support and handle leading spaces

Open ppavankumar19 opened this issue 1 month ago • 0 comments

Summary:

This Pull Request improves the existing capitalize() function by making it more robust and user-friendly. The function now properly capitalises the first alphabetical character, handles Unicode letters, and preserves leading spaces — all while maintaining backward compatibility.

Changes Introduced:

Added logic to locate the first alphabetic character (not just index 0).

Added support for Unicode characters such as ñ, ö, ç, etc.

Preserved the original structure of the string, including leading spaces.

Improved and expanded doctest examples for better coverage.

I'd like for you to ensure safe handling of empty strings and strings without alphabetic characters.

ppavankumar19 avatar Nov 25 '25 14:11 ppavankumar19