Mar-18-2019, 07:19 PM
Hello all,
So I'm trying to take a message and compare it to elements in a list, here is example code
Example wanted inputs to outputs:
message = 'foo hello' ------> output: foo
message = 'foo bar testing' ------> output: foo bar
message = foo foo bar ------> output: foo
I may not have explained this super well, but any help would be greatly appreciated on how to achieve these outputs.
So I'm trying to take a message and compare it to elements in a list, here is example code
message = 'foo bar hello' example_list = {'foo bar', 'foo'} if message beginswith strings_In_example_list_index print(the_index_in_the_list)The last two lines are just pseudocode, because I don't know how to finish it. Given a list of any number of elements, in this case just two, if message begins with a string that is in the list, I just want it to print that element that was found to begin in the message.
Example wanted inputs to outputs:
message = 'foo hello' ------> output: foo
message = 'foo bar testing' ------> output: foo bar
message = foo foo bar ------> output: foo
I may not have explained this super well, but any help would be greatly appreciated on how to achieve these outputs.