- Students often try to write something like the following to check every item in a list:
- The block above reads:
"hello" = item (any) of (list)
- This will fail most of the time because any is a random item.
- The
contains
block is what students should use in order to achieve the task they are trying to complete: - The block above reads:
(list) contains "hello"
- This block reports whether or not the item exists in the list. If the item if found, it reports TRUE, otherwise it will report FALSE.
- You can actually make your own version of
contains
! - Here’s one way to create
contains
in Snap!