Jul-20-2020, 06:30 AM
(This post was last modified: Jul-20-2020, 06:30 AM by knoxvillerailgrind.)
Hi,
i´m rewriting a program for a psychological experiment. The existing code only accepts the response in a certain length. The first part is about lowering the name and response for comparison and hasSubstring is a new variable, is it? I´ve tried learning the functions len, range, if and for but i cant put them together in this code..
Anyone can explain to me how the code works and how i rewrite it to just compare the response with name?
Thanks!
i´m rewriting a program for a psychological experiment. The existing code only accepts the response in a certain length. The first part is about lowering the name and response for comparison and hasSubstring is a new variable, is it? I´ve tried learning the functions len, range, if and for but i cant put them together in this code..
Anyone can explain to me how the code works and how i rewrite it to just compare the response with name?
Thanks!

___prepare__ def checkIfContains(name, response): name = name.lower(); response = response.lower(); stringFragments = [] for i in range(0,len(response)-3): stringFragments.append(response[i:i+5]) hasSubstring = False; for i in range(0,len(stringFragments)-1): if stringFragments[i] in name: hasSubstring = True; return hasSubstring __end__