Why this doesnt work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By axilirate
var player_list = {}

func update_player_list():
	for player in $PlayerList.get_children():
		player_list.clear()
		player_list[player.text] = player.text
		print(player.text) #returns 1
		print(player_list[player.text]) #returns 1
		print(player_list[1]) #error

The key values are of different types. You assign a value to the dictionary key “1” (String) but query the value for 1 (float).
Try:
print(player_list["1"])
this may also work:
print(player_list[str(1)])

wombatstampede | 2020-04-06 09:36

yea that’s worked.

axilirate | 2020-04-06 09:44