Home > Enterprise >  how do i find a character in a text and then copy the word that had that character python
how do i find a character in a text and then copy the word that had that character python

Time:07-07

i want to extract a word out of a string based on what character it got, for Example:

string: I WANT TO EAT cheese in zeven11

Extract all words with 11 in it

extracted: Zeven11

i try find() method but then i only get a on number of the word

CodePudding user response:

Maybe something like this:

for word in string.split():
    if '11' in word: print(word.capitalize())  # first letter?
  • Related