pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

List

Example

Array processing is used with array functions

from m5stack import *
from m5ui import *
from uiflow import *

list01 = None
list02 = None

def first_index(my_list, elem):
  try: index = my_list.index(elem) + 1
  except: index = 0
  return index

list01 = []
list02 = [1, 2, 3, [4, 5, 6]]
print(len(list02))
print(not len(list01))
print(list02[1])
print(first_index(list02, 1))
print(list02[2 : 4])
print(list(reversed(list02)))

list02[-1] = 9
print(list02)

list01 = [2] * 2
print(list01)

print('1,2,3,4'.split(','))

API

list01 = []
  • Create a custom empty list
list02 = [1, 2, 3, [4, 5, 6]]
  • Build a list using elements repeated a certain number of times
print(list02[1])
  • Get the value of an element at a specific index in the list
print(list02[2 : 4])
  • Slice elements from the list to create a new list
print(first_index(list02, 1))
  • Access an element in the list by index, either in forward or reverse order
print(not len(list01))
  • Check if a list is empty, returning True if it is, and False otherwise
print(len(list02))
  • Measure the length of the list (i.e., the number of elements in the list)
list01 = [2] * 2
print(list01)
  • (Note: This is a duplicate of the previous functionality) Build a list using elements repeated a certain number of times
print(list(reversed(list02)))
  • Reverse the order of elements in the list
list02[-1] = 9
print(list02)
  • Set a specific value at a given index in the list
print('1,2,3,4'.split(','))
  • Create a list from text, using a delimiter
On This Page