title: How to either add an '!' if one does not exist, or remove any additional ones out of a string?
body: <p>I've written a script that does an API call to our golden config site, pulls down only the ACLs, and spits them out into a Jinja2 file to be imported into a base config.  This was all done via regex.</p>
  <p>What i'm trying to do is add an exclamation point on the bottom of each ACL if one doesn't exist, or remove any extra lines if they do exist below this exclamation point.</p>
  <p>Here is what I have, and while it may work, I sense it can run into issues so i'm looking for a cleaner version (figure an ACL is assigned to the variable 'acl', and is currently a string)</p>
  <pre><code>acl = acl.splitlines()
  
  if acl[-1] != '!':
      acl.append('!')
  </code></pre>
  <p>Any help would be appreciated.  My concern with above is if there's an empty line after an '!' it would still add it, and maybe some others that I cannot think of at the moment.</p>