how to use has() in the array?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ismaelgame7
:warning: Old Version Published before Godot 3 was released.

Hello, can anyone tell me how to use has() in the array?
I’m having trouble checking if there is an item in the array :confused:

var myArray = [["notebook",0],["book",1],["phone",2]]
var listID = 1
    if myArray.has(myArray[listID]):
    	myArray.remove(listID)
    pass

In this example I’m trying to check if an index 1 in array
only that Godot points this error >> Invalid get index ‘1’ (on base: ‘Array’).

Can someone help me please!?

:bust_in_silhouette: Reply From: Kamil Lewan

Do you want get 2nd var in that small arrays e.g. [“book”,1]?

for i in myArray:
   if i[1] = listID
      myArray.remove[i]

should work.
pass is not necessary. It does nothing.
PS. Please write more exactly WHAT do you want to get.
PS1. Please write line of code where you got error (3,4?)

Use == in an if statement.

blue_robin | 2021-11-09 01:20

:bust_in_silhouette: Reply From: ismaelgame7

I want to get an index from my array and remove it
Type: var listID = 1
Var myArray = [[“notebook”, 0], [Delete], [“phone”, 2]]
The error is just in this line >> if myArray.has(myArray[listID])
I know that the pass does nothing, I just use it to make it cute
It’s hard to express yourself on the internet, I try but I’m not very good at it. kkkkkk

:bust_in_silhouette: Reply From: ismaelgame7

My friend helped me here.
So my code looks like this:

if (listID < imagens.size()):
   myArray.remove(listID) 
  pass
:bust_in_silhouette: Reply From: luislodosm
var my_array = ["one", "two", "three", "four"]

if my_Array.has("three"):
    # do stuff

or

if "three" in my_array:
    # do stuff