title: Python3: for-loop break and else (if statement)
body: <h1>Background information:</h1>
  <p>hey,
  I want to do the following: I have a dictionary with IDs as keys and lists with various things as value. One of the items of the value is a <strong>string</strong>. I want to check, if a list contains this <strong>string</strong>. And I want to do it for all keys in my dictionary.</p>
  <ul>
  <li>If the list contains the string, I want to print &quot;String is valid&quot;</li>
  <li>If the list does not contain the string, I want to print &quot;String is NOT valid&quot;</li>
  </ul>
  <p>So far, so good.</p>
  <p>Furthermore, the lists I want to check depend on one console input of the user, which specifies, which list should be checked. The console input is <strong>&quot;number&quot;</strong>.</p>
  <p>My idea was to iterate over my dictionary and my list with a nested for-loop and compare, if the string(the item of the value) is equal to any list item. If it is, I want to break out of the loop. If the String is not found in the list, I want to execute the else-statement to print my &quot;String is not valid&quot; message.</p>
  <h1>Code snippet:</h1>
  <pre><code>def validationHelper(myDict, myList):
          for key in myDict:
              for value in myDict[key][0]:
                  for item in myList:
                      if value==item:
                          validationHelper.true=&quot;String is valid&quot;
                          break
                  else:
                      validationHelper.true=&quot;Warning: String is NOT valid&quot;
            
  def validation(anyList,helperfunc):
      if anyList==&quot;one&quot;:
          return helperfunc(finalDict,myList1)
      if anyList==&quot;two&quot;:
           return helperfunc(finalDict,myList2)
      if anyList==&quot;three&quot;:
           return helperfunc(finalDict,myList3)
  
  validation(number, validationHelper)
  
  print(validationHelper.true)
  </code></pre>
  <h1>Problem:</h1>
  <p>I am running this, but no matter if the string is in the list or not, I always get my printout for the else-statement. So, I guess I have an error in reasoning in my for-loop? Or maybe, I did not understand for-loops at all?! I have tried out different indentions with the else-statement, but couldnt solve my problem.</p>