title: Python - Find number of characters that are found in both string1 and string2
body: <p>I'm trying to find the number of characters in the first string that are also found in the second string. This is what I have so far:</p>
  
  <pre><code>def main():
      text1 = raw_input("Enter word 1: ")
      text2 = raw_input("Enter word 2: ")
  
      print("The number of characters that occur in both", text1, "and", text2, "is", count)
  
  def count(text1, text2):
      char = 0
      for i in text1:
          for j in text2:
              if i == j:
                  char += 1
  
      return char
  
  main()
  </code></pre>
  
  <p>I'm having trouble at def count(). I'm not sure how I can count how many letters occur in text1 and text2 that won't be repeated. Any help is appreciated!</p>