Subtract one list from another list

I provision subnets in all availability zones.
I want a user to specify one or more availability zones to skip.

This seems like a use case for: https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each
This is an example of when you have single known item you want to remove from a list: https://github.com/hashicorp/terraform/issues/16044#issuecomment-368111237

Thoughts on how to remove all items in one list from another list? Is there documentation in what language the for is written in? Can I do two loops? Anything more efficient?

Anyone have any thoughts on how to accomplish this?

Hi @throwaway8787!

We can generalize the idea I shared in that issue with any other condition, including a call to contains:

  example = [
    for x in var.any_list : x if !contains(var.to_remove, x)
  ]