<?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: Python Help For Beginner in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208319#M16095</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Or...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

List = [value1, value2, value3, value4]
matches = [s for s in List if len(s)==5]
for m in matches:
&amp;nbsp; print m

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:17:23 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2021-12-11T10:17:23Z</dc:date>
    <item>
      <title>Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208316#M16092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another python question for the forum, this one should be easy. I am trying to complete the following exercise and am stumped with the last section. I am asked to print only the items in the list with exactly 5 characters. If anyone can help me out that would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Create list with these four entries: roads, streams, parks, contours value1 = "roads" value2 = "streams" value3 = "parks" value4 = "contours"&amp;nbsp; List = [value1, value2, value3, value4]&amp;nbsp; # Print the first entry in the list to the interactive window print List[0]&amp;nbsp; # Use a loop to print every entry that has exactly 5 # characters to the interactive window&amp;nbsp; print List &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brett&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2014 15:16:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208316#M16092</guid>
      <dc:creator>BrettAuger1</dc:creator>
      <dc:date>2014-06-03T15:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208317#M16093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python has a length() test:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Create list with these four entries: roads, streams, parks, contours
value1 = "roads"
value2 = "streams"
value3 = "parks"
value4 = "contours"

List = [value1, value2, value3, value4]

# Print the first entry in the list to the interactive window
print List[0]

# Use a loop to print every entry that has exactly 5
for val in List:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(val) == 5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '{0} has a length of 5 characters'.format(val)
# characters to the interactive window


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:11:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208317#M16093</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T16:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208318#M16094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perfect, works just fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2014 16:04:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208318#M16094</guid>
      <dc:creator>BrettAuger1</dc:creator>
      <dc:date>2014-06-03T16:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208319#M16095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Or...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

List = [value1, value2, value3, value4]
matches = [s for s in List if len(s)==5]
for m in matches:
&amp;nbsp; print m

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:17:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208319#M16095</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T10:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208320#M16096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Even more pythonic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

value1 = "roads"
value2 = "streams"
value3 = "parks"
value4 = "contours"

List = [value1, value2, value3, value4]

for match in [s for s in List if len(s)==5]:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print match

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208320#M16096</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T10:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208321#M16097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Even more pythonic:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

value1 = "roads"
value2 = "streams"
value3 = "parks"
value4 = "contours"

List = [value1, value2, value3, value4]

for match in [s for s in List if len(s)==5]:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print match

&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks James.&amp;nbsp; This is definitely the better answer, but list comprehensions are probably not very easy to understand for a beginner.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208321#M16097</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T10:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python Help For Beginner</title>
      <link>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208322#M16098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks James.&amp;nbsp; This is definitely the better answer, but list comprehensions are probably not very easy to understand for a beginner.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Heck, I still struggle with them!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OP -- Caleb's answer is exactly how I have it in 99% of my code but I'm starting to write in a more pythonic style.&amp;nbsp; I just thought a different approach would be good to see!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2014 17:39:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-help-for-beginner/m-p/208322#M16098</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-06-03T17:39:02Z</dc:date>
    </item>
  </channel>
</rss>

