<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Reading from a List]]></title><description><![CDATA[<h2><a class="anchor-offset" name="prerequisite"></a>Prerequisite</h2>
<ul>
<li><a href="/topic/88/editing-a-list-using-blocks">Editing a List Using Blocks</a></li>
</ul>
<h2><a class="anchor-offset" name="description"></a>Description</h2>
<p dir="auto">A list is just like many variable items positioned sequentially. You can read the value of any item using its position, or get information about the list itself.</p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="getting-the-length-of-a-list"></a>Getting the Length of a List</h2>
<p dir="auto">This reporter block tells you how many items are in the list.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1ab485eb-845f-4cfe-9b0d-0ad56c216057.png" width="245" style="filter:drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5))" /></p>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="demo"></a>Demo</h3>
<p dir="auto">Note that the position indices of the items go from 1 to the list length. For example, if you want to <strong>insert an item before the last item of a list</strong>, you can use the list length as the position.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/bbc54e82-907c-4cbb-923d-83f2706c50b4.gif" width="970" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="reading-an-item-s-value-at-a-position"></a>Reading an Item’s Value at a Position</h2>
<p dir="auto">If you know the position of an item, you can read its value using this block:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/95d4f784-1d6e-42d7-b966-ddd3eacdce09.png" width="297" /></p>
<p dir="auto"><strong>The position index has to be at least 1 and at most the length of the list</strong>. For example, to get the last item’s value, you can do this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4177dbc4-71d8-4ab8-9a4f-7b546a117b85.gif" width="970" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="searching-for-an-item-by-its-value"></a>Searching for an Item by Its Value</h2>
<p dir="auto">You can not only get an item by its position, but also find the position of an item if you know its value.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/42000a98-2f4d-46fb-bd66-828c4446d84d.png" width="300" /></p>
<p dir="auto"> <br />
<strong>If the value is not found, then the reported value will be 0:</strong></p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b47db0ca-34d3-4274-8b60-d098b23a736d.gif" width="530" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="whether-a-value-is-in-the-list"></a>Whether a Value is In the List</h2>
<p dir="auto">You can find out if a value is contained in a list using this boolean block, which will report “true” or “false”.</p>
<p dir="auto"> <br />
<img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/00074c7a-d2ce-489d-a7ad-1321ad5dc214.gif" width="539" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="searching-for-a-part-of-an-item"></a>Searching for a part of an item</h2>
<p dir="auto">Sometimes you want to find any item that contains some value. In other words, you are searching for a part of an item. You can use this block:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b819fc8f-19e0-4a93-be9f-101a9323c060.png" width="400" /></p>
<p dir="auto">For example, in the list of student names, you might want to find the index of the first item that contains “Mike” like this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/16aba739-eb33-42df-afa0-611fd0157be0.gif" width="680" style="border-radius:5px;border:1px solid #29622d" /></p>
]]></description><link>https://forum.creaticode.com/topic/89/reading-from-a-list</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 04:57:04 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/89.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Mar 2022 16:22:11 GMT</pubDate><ttl>60</ttl></channel></rss>