For example, I have a string variable line
(line.contains("for") || line.contains("def") || line.contains("if") || line.contains("while") || line.contains("else") || line.contains("elif")
and I want to set a new string variable keyword to the keyword in this conditional statement, how would be able to do this, like keyword = keyword in line.
line.contains("if") || line.contains("elif")is redundant; if the line does not contain"if", then it won't contain"elif".List.contains()is wrong. Then you have to use a parser, to correctly identify and process the different elements of your input. What if the line isif a == "def"or something like that?