0
I am writing a Python3 script, in order to place a filter to prevent the user from passing a string containing an offensive or improper word.
So I created a list containing the words I want to put this filter in and then I treated them with the operators not in and in and when the condition not in is met want to continue the script execution and when the condition in is met want to return the execution alerting the user that the string passed by it contains an offensive word
I even managed to make the script work, but only when the string passed is == to the value contained in the list.
I wanted to make this filter more complete by analyzing all the text and if a part of the string contains the value contained in the list, I wanted the script to also execute the instruction code block in
Below I’m putting the script:
class Textoofencivo():
def verifica():
texto = input('Digite um texto: ').strip()
texto_formatado = texto.upper()
my_list = [
"AAA", "BBB"
]
iniciar = None
while(iniciar == None):
if(texto_formatado not in my_list):
print('\n' * 1)
print('Bem Vindo')
print('\n' * 1)
###### CONTINUA O SCRIPT #####
break
elif(texto_formatado in list(my_list)):
print('\n' * 1)
print('O texto informado contem uma
palavra ofensiva\nRetornando a Execução')
print('\n' * 1)
###### RETORNA A EXECUÇÂO ANTERIOR ######
texto = None
return TextoOfencivo.verifica()
Textoofencivo.()
Can someone help me ? Thank you in advance!!!
Sincerely yours truly, Michael de Mattos
Thank you very much! Solved my problem and the explanation was note 10.
– Michael Mattos