Q:

Function that returns the list index of a substring

I am struggling trying to create a function which searches a list to see if any of the strings contained within it are substrings of any of the other strings within the same list. If a substring is found it should return the index number and if none are found it should return False
For example.
lst1 = ["red", "yellow", "green", "yellowhammer"]
lst2 = ["red", "yellow", "green"]

In this example, lst1 would return a value of 1 as yellow is a substring of yellowhammer and lst2 would return a value of False as there are no substrings.
I have tried the following 
templst = lst1
for i in templst:
    if i in lst1:
       return i
    else:
        return False

However this does not work because it always finds itself so even if there are no substrings it returns a value even if it should return False.

A:

The following code should accomplish what you need. The details of how this is accomplished are commented within.
# Lists that OP provided
lst1 = ["red", "yellow", "green", "yellowhammer"]
lst2 = ["red", "yellow", "green"]

# Function that checks the list
def checkList(myList):
        # Create a variable to hold the concatenated string
        total = ""

        # Build the concatenated string
        for item in myList:
                total += item

        # Loop through the list again
        for i, item in enumerate(myList):
                # Count the amount of times each item appears in the concatenation
                curr = total.count(item)
                # If its more than one, since it will always appear once
                if(curr > 1):
                        # Return its index
                        return i
        # Otherwise, return False
        return False
# Test the two test samples
list_1_ans = checkList(lst1)
list_2_ans = checkList(lst2)

# Print out results
print("First Test Answer: {} | Second Test Answer: {}".format(list_1_ans, list_2_ans))

Yields:
First Test Answer: 1 | Second Test Answer: False

