title: Python - Check if letter appears in consecutive words
body: <p>I have a task where I need to read input and check if that input occurs in some words. For example:</p>
  
  <pre><code>Who are your friends? Fred Bill Sue Simone
  What is the message? Should you make tea?
  Sue could have written this.
  </code></pre>
  
  <p>It prints "Sue could have written this because the letters "S", "U" and "E" appear in the each consecutive word. Another example is:</p>
  
  <pre><code>Who are your friends? James Nicky Jake
  What is the message? join and make enough cash today!
  James could have written this.
  Jake could have written this.
  </code></pre>
  
  <p>Both names are printed because both of their letters appear consecutively in each word. I have the following code:</p>
  
  <pre><code>friends = input("Who are your friends? ").split()
  message = input("What is the message? ").split()
  
  name = []
  other = []
  
  for friend in friends:
    for f in friend.lower():
      for word in message:
        print("checking if", f, "is in", word.lower())
        if f in word.lower():
          print("Adding", f, " to name list")
          name.append(f)
          break
        else:
          other.append(f)
          continue
  
  joinedResult = ''.join(name)
  
  for person in friends:
    if person.lower() in joinedResult:
      print(person, "could have written this.")
  </code></pre>
  
  <p>It works perfect for the first example, but for the second example it prints all three names:</p>
  
  <pre><code>James could have written this.
  Nicky could have written this.
  Jake could have written this.
  </code></pre>
  
  <p>I have learnt that the code does not check if the letters in the name appear <strong>consecutively</strong>, rather it checks if the name is in any word. How do i solve this?</p>