<?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: Question re: list.extend  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444572#M34822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use .append instead of .extend - paraphrased from the &lt;A href="https://docs.python.org/2/tutorial/datastructures.html"&gt;python docs&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;list.append(x)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add an item to the end of the list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;list.extend(L)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Extend the list by appending all the items in the given list&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e append is for adding a single item to the list, extend is for adding multiple items in a list to the list&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jan 2016 23:37:33 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2016-01-26T23:37:33Z</dc:date>
    <item>
      <title>Question re: list.extend</title>
      <link>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444569#M34819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm a new Python student. Using a loop, I need to add to a list. The following is not working. Not sure what I'm missing or if my logic is bad.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Variables&lt;/P&gt;&lt;P&gt;myList = []&lt;/P&gt;&lt;P&gt;item = ''&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create name list&lt;/P&gt;&lt;P&gt;item = raw_input("Please enter a name or blank to quit: ")&lt;/P&gt;&lt;P&gt;while item &amp;lt;&amp;gt; '':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myList.extend(item)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printmyList&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp; File "C&lt;/SPAN&gt;:&lt;SPAN style="color: #e23d39;"&gt;/Users/&lt;/SPAN&gt;ken&lt;SPAN style="color: #e23d39;"&gt;/Desktop/HW4b&lt;/SPAN&gt;.py&lt;SPAN style="color: #e23d39;"&gt;", line 14, in &amp;lt;&lt;/SPAN&gt;module&lt;SPAN style="color: #e23d39;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;myList.&lt;SPAN style="color: #e23d39;"&gt;extend&lt;/SPAN&gt;(&lt;SPAN style="color: #e23d39;"&gt;item)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;MemoryError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks ... Ken&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:35:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444569#M34819</guid>
      <dc:creator>KennethKirkeby</dc:creator>
      <dc:date>2016-01-26T21:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Question re: list.extend</title>
      <link>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444570#M34820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myList = []

item = ''

#Create name list

item = None

while item &amp;lt;&amp;gt; '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; item = raw_input("Please enter a name or blank to quit: ")
&amp;nbsp;&amp;nbsp;&amp;nbsp; myList.append(item)
print myList&lt;/PRE&gt;&lt;P&gt;You need to ask for a new input on each iteration of the loop. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:52:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444570#M34820</guid>
      <dc:creator>BillDaigle</dc:creator>
      <dc:date>2021-12-11T19:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Question re: list.extend</title>
      <link>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444571#M34821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Had to add the brackets to ITEM or the list was individual letters. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myList = []&lt;/P&gt;&lt;P&gt;Item = 'None'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while item &amp;lt;&amp;gt; '':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item = (raw_input("Please enter a number (Blank to quit): "))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myList.extend([item])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printmyList&lt;/P&gt;&lt;P&gt;************************************************************&lt;/P&gt;&lt;P&gt;Please enter a number (Blank to quit): Ken &lt;/P&gt;&lt;P&gt;Please enter a number (Blank to quit): Jim &lt;/P&gt;&lt;P&gt;Please enter a number (Blank to quit): Bill &lt;/P&gt;&lt;P&gt;Please enter a number (Blank to quit): &lt;/P&gt;&lt;P&gt;['Ken', 'Jim', 'Bill', '']&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 22:34:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444571#M34821</guid>
      <dc:creator>KennethKirkeby</dc:creator>
      <dc:date>2016-01-26T22:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Question re: list.extend</title>
      <link>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444572#M34822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use .append instead of .extend - paraphrased from the &lt;A href="https://docs.python.org/2/tutorial/datastructures.html"&gt;python docs&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;list.append(x)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add an item to the end of the list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;list.extend(L)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Extend the list by appending all the items in the given list&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e append is for adding a single item to the list, extend is for adding multiple items in a list to the list&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 23:37:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-re-list-extend/m-p/444572#M34822</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-01-26T23:37:33Z</dc:date>
    </item>
  </channel>
</rss>

