0

I have a code but it doesn't work as I want. I need to call (or print) the initial letter of each element in the array as uppercase.

Or alternatively: automatically converting the first letter of every word I type in the text box to uppercase will solve my problem.(in real time)

How can I do that?

    editline_text = self.search_item_editline.GetText()
    new_list = [x for x in autoComplete.AUTOCOMPLETE_DIC_NAMES if editline_text in x]
    index = 1
    for item in new_list:
        if index > 10:
            break
        index += 1
        self.editline_list.AddItem(item)
cvaqabond
  • 23
  • 3
  • See [How to Uppercase the First Letter of a Word in Python](https://learnpython.com/blog/uppercase-letter-python/). – jarmod Mar 28 '23 at 16:07
  • It's a good idea to try to learn proper terminology - that makes it much easier to look for existing information, and also make yourself clearly understood when asking questions. "call" does not mean anything like what you appear to think it means. Actually I can't really tell what you think it means, but it **only** means using the call syntax: code like `x(y)` is "calling" `x`. – Karl Knechtel Mar 28 '23 at 16:34
  • @jarmod that article shouldn't be taken literally, it is possible to have a word with the first letter capital, and remaining letters lowercase, but return false when tested with str.istitle(). Python title casing actually converts the first alphabetic character after a non-alphabetic character to uppercase. This is at a start of a word, or within a word when non-alphabetic characters such as apostrophe, hyphen, combining diacritic, etc occur within the word. It's one of the fun aspects of python that isn't explicitly documented. The definition also has implications elsewhere in Python. – Andj Apr 11 '23 at 16:28
  • @Andj thanks, agree that there are subtleties with istitle() e.g. with variants of "O'Malley". – jarmod Apr 11 '23 at 17:03
  • 1
    @jarmod, for English they may be subtleties, but if you work with NFD normalised data, or African languages, or Vietnamese typed on Windows, the effects aren't subtle, it is blantant. Take something like `gɛ̈mgɛ̈m dɔ̈ɔ̈r ëbɛ̈nëbɛ̈n` python title casing transforms it to `Gɛ̈Mgɛ̈M Dɔ̈Ɔ̈R Ëbɛ̈Nëbɛ̈N` – Andj Apr 11 '23 at 17:49

0 Answers0