Str.count() not working?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stevepetoskey

So I am using the code:

string.count(" ")

But when it runs the code it gives the error:

Method 'count' is not declared on base 'String'.

I checked the godot engine docs and count() is a thing yet it won’t work for me. I also tried

"    ".count(" ")

In the _ready(): function as well and still got the same error. Any help would be appreciated

:bust_in_silhouette: Reply From: whiteshampoo

I tried it by myself:

func _ready():
	var string : String = "Bla Bla Bla"
	print(string.count(" "))

is working fine and prints


as expected.
Can you show more code, maybe the error is somewhere else.