<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Truncate String - Remove Space in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571218#M44796</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/jamesfreddyc"&gt;jamesfreddyc&lt;/A&gt;‌, the variable is the name given to individual features (1000's of them), so there will never be a space at the beginning, but there could be a space anywhere in the name of the feature.&amp;nbsp; The variable is part of a concatenation script, but I need that concatenation script to adhere to a maximum set of characters.&amp;nbsp; Since the variable names can range from only a few characters on up to ~100 characters, I need to truncate it.&amp;nbsp; All other parts of the concatenation are standard, so I need to truncate the feature name to 14 characters or less, which places me right at the limit required.&amp;nbsp; The problem is that there are instances where the 14th character just so happens to land on a space, and I need to remove that last space in those instances.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;‌, I don't need to join the strings back together or anything, I just need to remove the last one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My end concatenation looks something like this:&lt;/P&gt;&lt;P&gt;(AB-CD-EFGHIJKL-12345)-(Variable)-(XYZ)-(01)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable portion is what I'm trying to fix.&amp;nbsp; If the space is left there, then there's an unnecessary space that we want to remove.&amp;nbsp; Instead of "(SAMPLE_)", we need "(SAMPLE)", however, if the name so happens to be "SAM PLE" then we want to retain that space and end up with "(SAM_PLE)".&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Sep 2017 19:37:38 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2017-09-26T19:37:38Z</dc:date>
    <item>
      <title>Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571213#M44791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to implement a truncation in my script, which is easy enough, but I need to make the overall script smart enough to remove the last character if it happens to be a space.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, if I have the following code:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAMPLE NAME"&lt;/SPAN&gt;
truncVar &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This ends up returning "SAMPLE ", which is right, but there's a space at the end of the string.&amp;nbsp; I need the script to check for that space, and delete it if it's there, otherwise leave the last character.&amp;nbsp; I can't just reduce the truncated value since the actual names in the variables will vary widely.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Working Script based on correct answer:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"This is a test variable"&lt;/SPAN&gt;
trunc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; result
&lt;SPAN class="string token"&gt;'This is a'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# The strip operation removed the ending space, but it left all others&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571213#M44791</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T00:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571214#M44792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd think split() is a better method as long as the space between the two words is how you identify what to evaluate.&amp;nbsp; That way it doesn't have to be a set number of characters to the left or right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAMPLE NAME"&lt;/SPAN&gt;
splitVar1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; splitVar1&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571214#M44792</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T00:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571215#M44793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have expanded a bit more. There is a potential that there could be a space somewhere before the truncated number of characters.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;So instead of "Sample_Name" with only one space, we could potentially have "Sam_ple_Name" with two spaces.&amp;nbsp; In the second instance, I need to only remove the last space.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;*NOTE* I understand that [:7] as highlighted in my original post would not return both spaces in my second scenario, but the [:7] is theoretical for example only.&amp;nbsp; There are inevitably going to be examples where I have two spaces, but only need one removed if it happens to be the last character.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:06:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571215#M44793</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-09-26T19:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571216#M44794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you clarify that you want&amp;nbsp; "SAMPLE" as an output from these possibilities?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"SAMPLE NAME"&lt;/P&gt;&lt;P&gt;"SAM PLE NAME"&lt;/P&gt;&lt;P&gt;" SAM PLE NAME"&lt;/P&gt;&lt;P&gt;" SAM PLE NAME "&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:17:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571216#M44794</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-09-26T19:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571217#M44795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;are you trying to split on spaces? How complex is it going to get? Do you want to close the gap except for the last one? like this one?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Sam ple space'&lt;/SPAN&gt;
a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Sam'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ple'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# ----&amp;nbsp; now slice and splice in one go&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'Sample'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571217#M44795</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571218#M44796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/jamesfreddyc"&gt;jamesfreddyc&lt;/A&gt;‌, the variable is the name given to individual features (1000's of them), so there will never be a space at the beginning, but there could be a space anywhere in the name of the feature.&amp;nbsp; The variable is part of a concatenation script, but I need that concatenation script to adhere to a maximum set of characters.&amp;nbsp; Since the variable names can range from only a few characters on up to ~100 characters, I need to truncate it.&amp;nbsp; All other parts of the concatenation are standard, so I need to truncate the feature name to 14 characters or less, which places me right at the limit required.&amp;nbsp; The problem is that there are instances where the 14th character just so happens to land on a space, and I need to remove that last space in those instances.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;‌, I don't need to join the strings back together or anything, I just need to remove the last one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My end concatenation looks something like this:&lt;/P&gt;&lt;P&gt;(AB-CD-EFGHIJKL-12345)-(Variable)-(XYZ)-(01)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable portion is what I'm trying to fix.&amp;nbsp; If the space is left there, then there's an unnecessary space that we want to remove.&amp;nbsp; Instead of "(SAMPLE_)", we need "(SAMPLE)", however, if the name so happens to be "SAM PLE" then we want to retain that space and end up with "(SAM_PLE)".&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571218#M44796</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-09-26T19:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571219#M44797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look into &lt;A href="https://www.tutorialspoint.com/python/string_strip.htm"&gt;strip().&lt;/A&gt;&amp;nbsp; If you don't pass any parameters, the function will remove spaces before and after a string. &amp;nbsp;I don't know if that will help or not.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:44:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571219#M44797</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2017-09-26T19:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571220#M44798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAMPLE NAME"&lt;/SPAN&gt;
truncVar &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;variable&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rfind&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571220#M44798</guid>
      <dc:creator>KevinDunlop</dc:creator>
      <dc:date>2021-12-12T00:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571221#M44799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The variable portion is what I'm trying to fix.&amp;nbsp; If the space is left there, then there's an unnecessary space that we want to remove.&amp;nbsp; Instead of "(SAMPLE_)", we need "(SAMPLE)", however, if the name so happens to be "SAM PLE" then we want to retain that space and end up with "(SAM_PLE)".&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not entirely skilled in string manipulation and there's&amp;nbsp;likely far better solution --&amp;nbsp;so this is quite limited in scope and&amp;nbsp;would only account for the above scenario if the variable is "SAMPLE " or "SAM PLE NAME".&amp;nbsp; But perhaps it might give you some ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;truncVar &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;
variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAM PLE NAME"&lt;/SPAN&gt;
splitVarList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;splitVarList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; truncVar &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; splitVarList&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;splitVarList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; truncVar &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%s%s"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;splitVarList&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;splitVarList&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; truncVar&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571221#M44799</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T00:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571222#M44800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That did the trick.&amp;nbsp; Thanks, &lt;A href="https://community.esri.com/migrated-users/22865"&gt;Kevin Dunlop&lt;/A&gt;‌!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is exactly what I was looking for:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/373619_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 20:09:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571222#M44800</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-09-26T20:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571223#M44801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was under the impression that this also needs to account for "SAMPLE NAME" or&amp;nbsp;"SAM PLE NAME"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 20:11:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571223#M44801</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-09-26T20:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571224#M44802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/7306" target="_blank"&gt;James Crandall&lt;/A&gt;‌, I didn't test this out fully enough.&amp;nbsp; It worked on the sample I had above, but I ran this same test on different variables and it didn't quite work.&amp;nbsp; I was a bit too hasty there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAMPLE NAME"&lt;/SPAN&gt;
trunc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;8&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
string &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; string
&lt;SPAN class="string token"&gt;'SAMPLE N'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# last character is not a space&lt;/SPAN&gt;

truncRemove &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; trunc&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;trunc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rfind&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
string2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; truncRemove &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; string2
&lt;SPAN class="string token"&gt;'SAMPLE'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# I don't want the "_N" removed&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Since the last character returned in trunc is not a space, the desired result is what was returned in the first print string operation&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for catching that, &lt;A href="https://community.esri.com/people/jamesfreddyc" target="_blank"&gt;jamesfreddyc&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571224#M44802</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T00:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571225#M44803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/159379" target="_blank"&gt;Mitch Holley&lt;/A&gt;‌ already provided the answer, i.e., set your truncation width and then simply run &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;strip()&lt;/SPAN&gt; to remove any leading or trailing spaces.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAMPLE NAME"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; string &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; string
&lt;SPAN class="string token"&gt;'SAMPLE'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571225#M44803</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T00:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571226#M44804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This does seem to check out.&amp;nbsp; I was under the impression that strip would remove all spaces, or only a specified character. The example at the link that he provided showed the removal of only the zeros from the string, and that didn't seem to be what I needed.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Thanks for clarifying.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/people/mitchh300"&gt;mitchh300&lt;/A&gt;‌, thank you for that suggestion.&amp;nbsp; I have marked your answer as correct.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 21:07:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571226#M44804</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-09-26T21:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571227#M44805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will still need to account for the possible conditions.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work for "SAMPLE NAME".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will fail for "SAM PLE NAME"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SAM PLE NAME"&lt;/SPAN&gt;
trunc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
string &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571227#M44805</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T00:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571228#M44806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whenever I run the above code that you provided, I get "SAM_PLE" as a result, which is correct given that that makes up the 7 characters.&amp;nbsp; If I extend that out to 8 characters to grab that extra space, the strip function removes the last space and just returns the 7 characters, which is the desired result since I only want to remove the ending space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you get something different, or are we crossing wires on what the desired results are?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 21:20:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571228#M44806</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-09-26T21:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571229#M44807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if variable = "SAM PLE NAME" then the string result will be "SAM PLE", not "SAMPLE".&amp;nbsp; I was in response to what Joshua posted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt; variable &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;"SAMPLE NAME"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt; trunc &lt;SPAN&gt;=&lt;/SPAN&gt; variable&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;strip&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt; string &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;"'"&lt;/SPAN&gt; &lt;SPAN&gt;+&lt;/SPAN&gt; trunc &lt;SPAN&gt;+&lt;/SPAN&gt; &lt;SPAN&gt;"'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;print&lt;/SPAN&gt; string&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 21:22:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571229#M44807</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-09-26T21:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate String - Remove Space</title>
      <link>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571230#M44808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see what you are saying now.&amp;nbsp; We were crossing wires a bit.&amp;nbsp; I probably didn't explain what was needed very well.&amp;nbsp; In using "SAM PLE" as my variable, I wasn't trying to indicate that I wanted them joined, I was just trying to simulate a space, and I used the original variable name that I used from the start so that probably came across confusingly.&amp;nbsp; I'll use a better example below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;variable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"This is a test variable"&lt;/SPAN&gt;
trunc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; variable&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; trunc &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; result
&lt;SPAN class="string token"&gt;'This is a'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The strip operation removed the last space in the string, but it left all other spaces, which is as desired.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:34:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/truncate-string-remove-space/m-p/571230#M44808</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T00:34:37Z</dc:date>
    </item>
  </channel>
</rss>

