String de check-in do Python
Cadeia de check-in
Para verificar se uma determinada frase ou caractere está presente em uma string, podemos usar as palavras-chave
in
ou not in
.
Exemplo
Verifique se a frase "ain" está presente no texto a seguir:
txt = "The rain in Spain stays mainly in the plain"
x = "ain" in txt
print(x)
Exemplo
Verifique se a frase "ain" NÃO está presente no texto a seguir:
txt = "The rain in Spain stays mainly in the plain"
x = "ain"
not in txt
print(x)