title: Checking for a lowercase character or space in a string. Boolean not working
body: <p>This is supposed to check if an entered string is a valid license number. A valid number cannot have any lower case letters or spaces. If I enter "cat", it should see that the character "c" is lower so it should set bool isValid to false, break from the loop and then print "cat is not a valid license number." However it doesn't and it just makes the bool isValid to whatever I set it to in the beginning which was true. So if I initialized it to false and input "CAT" isValid would still be false. </p>
  
  <pre><code>int main()
  {
      // Input
      cout &lt;&lt; "Enter a valid license number: ";
      string license_number;
      getline(cin, license_number);
      cout &lt;&lt; endl;
  
      // Initialize boolean
      bool isValid = true;
  
      // Loop to check for space or lowercase
      for (int i = 0; i &lt; license_number.size(); i++)
      {
          if (isspace(license_number[i]) || islower(license_number[i]))
          {
              bool isValid = false;
              break;
          }
  
          else
              bool isValid = true;
      }
  
      // Output
      if (isValid == true)
          cout &lt;&lt; license_number &lt;&lt; " is a valid license number." &lt;&lt; endl;
  
      else
          cout &lt;&lt; license_number &lt;&lt; " is not a valid license number." &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>