How do you search for strings within a string?

Sydney Ballard

I'm writing a pig latin decoder. This section works with 'qu' works but currently only is the third letter of the word is a vowel. I am implementing an if statement to get it to work for words that have a consonant as the third letter, but keep getting this error: TypeError: 'in ' requires string as left operand, not list

Here is my code:

if w[-2:] == 'ay':
        RegW = []
        y = w.find('-')
        beginningw = w[y:]
        if vowel not in beginningw[0]:
            RegW.append(beginningw[0:-2] + w[0:y])
        else:
            RegW.append('qu' + w[0:y])
        return RegW[0]

It works for these word: ay-quay (quay) iz-quay (quiz) eue-quay (queue)

but NOT an-quray (quran) (returns quan w/o if statement I'm trying to)

tjholub

If vowel is a list of vowel characters, I think you want this:

if beginningw[0] not in vowel:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I search within an list of strings in Elastic Search?

How do you search within XML tags in Oracle SQL?

How do you search for strings in a file which in turn is in an archive?

How do I search for string within a string in Haskell?

How do I append a string to an array of strings within a loop in C?

How do you escape characters within a string (JSON format) in golang

How do you sort a string within a class parameter?

How do you detect a string within a file name in batch?

How do you insert a string within a dynamic target using realloc()?

How do you assign a value to a string within a list?

How do I make a search filter that you can only search for a specifc element within a set of divs?

How do you filter a list of strings by a string in haskell?

How do you split a string into a list of strings all of length 3?

How do you fish out certain strings in a string? LUA

How do I search for a list of strings inside another string?

How do you search for a phrase on a page in Chrome? (Not a string match)

How do you use Jsoup to search for a string on a website?

How do you search MS SQL database for a particular string?

How do you search for a specific string in a linked list and return that value?

How do you make a c++ program search for a string?

How to search a string in an array of strings

How do you search with TransactionSearch?

How do you search by Id?

How do I search a string for multiple strings, and then replace them with other strings? (Python)

how do you create regex to subset data frame based on some search strings?

When using a unified search/address bar within a web browser, how do you force the browser to search for a typed URL?

How do you split a long string into two smaller strings, about the space character closest to the string's center?

How do I read a string enclosed within square braces in a file in C with each line containing several such strings

How to search for specific sequences of words within a string?