How are array types (lists and tuples) and for loops related in Python? [closed]

Lists:

  • They are mutable; that is, the elements inside of it are permitted to change.
  • They use bracket notation [].

Tuples:

  • They are immutable; that is, the elements it is comprised of are not permitted to change.
  • They use parentheses notation ().
  • Perform a little faster due to their immutability.

Both lists and tuples:

  • Can be iterated over (for x in elements)
  • Can be sliced (elements[1:3])
  • Can be indexed (elements[0])

Leave a Comment