Filipe Andrade Filipe Andrade - 21 days ago 4
Python Question

Python check if string got a certain word (or combination of characters)

Ok so I have this string (for example):

var = "I eat breakfast."

What i would like to do is to check if that string has the letters "ea", and I wanted to be able to put those values into a list.

I tried using var[x] but I can only have one character at the same time and not a word right?


Use word in sentence. For example:

>>> 'el' in 'Hello'
>>> 'xy' in 'Hello'

For your reference, check: python in operator use cases