Skip to main content

Index Of In

Returns the item number of the element in the list. Would return 0 if it is not in the list.

Index Of In block

Description

The Index Of In block returns the item number of the element in the list. Would return 0 if it is not in the list. This is a code block part of the Lists drawer.

Usage

Use Index Of In to find the position of an element within a list. This is useful for locating specific values, determining order, or accessing related elements at the same position in parallel lists.

Syntax

Inputs:

  • Any type of element to search for
  • A list to search in

Notes

  • Returns the index position (item number) if the element is found
  • Returns 0 if the element is not in the list
  • List indices in StarLogo Nova start at 1 (first element is at position 1)
  • If an element appears multiple times, returns the index of the first occurrence
  • Contains - Checks if an element exists in a list
  • Item number in - Returns the item at a specific index in a list
  • List - Creates a list with specified elements
  • Length of - Returns the number of items in a list