PipeSader
(PipeSader)
May 12, 2021, 5:23pm
#1
I would like to know what is wrong in my dictionary and how can I print it?
-- What's wrong in my dictionary?
local my_first_Dictionary =
{
key= "first_Key" value= 666555,
key= "second_Key" value= 111333
}
print()-- → i need print this dictionary here..
local my_first_dictionary = {
first_key = 666555,
second_key = 111333
}
for key, value in pairs(my_first_dictionary) do
print(key, value)
end
1 Like
you’ve got the syntax a bit off.
local dict = {
first_key = 666555,
second_key = 111333
}
print(dict.second_key)
1 Like
PipeSader
(PipeSader)
May 12, 2021, 5:29pm
#4
The147panda:
local my_first_dictionary = {
first_key = 666555,
second_key = 111333
}
for key, value in pairs(my_first_dictionary) do
print(key, value)
end
Thanks a lot guys! I think I got confused when I wrote everything
1 Like
The dictionary has to values in one line, I suggest you make separate dictionaries for each “key”.
local dictionary = {
key1 = {
key = "first_key";
value = 666555
},
key2 = {
key = "second_key";
value = 111333
}
}
To print it, you should use a pairs loop.