Code: Select all
default dutst = {
"1": 1,
"2": 2,
"3": 3,
}
screen dictest:
vbox:
for i in dutst:
text i
can somebody test it and make sure it's not just my computer doing it?
Code: Select all
default dutst = {
"1": 1,
"2": 2,
"3": 3,
}
screen dictest:
vbox:
for i in dutst:
text i
Quite not sure what you're trying to iterate over. If its the keys then you could do it like this.Kia wrote: ↑Sun Sep 01, 2019 11:51 am I tried this simple code expecting 1,2,3:but it gives me 1,3,2Code: Select all
default dutst = { "1": 1, "2": 2, "3": 3, } screen dictest: vbox: for i in dutst: text i
can somebody test it and make sure it's not just my computer doing it?
Code: Select all
for i in dutst.keys(): # use keys() method to iterate over the keys, or if you're iterating over the dictionary's values use values() method instead.
text i
My two cents:
Code: Select all
default dutst = {
"1": 1,
"2": 2,
"3": 3,
}
screen dictest():
hbox:
align (0.5, 0.1)
spacing 50
vbox:
for i in sorted(dutst.keys()):
text "\'{}\' - {}".format(i, dutst[i])
vbox:
for i in dutst.keys():
text "\'{}\' - {}".format(i, dutst[i])
# The game starts here.
label start:
"..."
show screen dictest
"... ..."
"..."
"?!"
I did, not as pretty as I like the code to be, requires a python block, importing something and creating an extra variable to pass it to a class. it does work though.
Code: Select all
default data = (('1', 1, 'foo'),
('2', 2, 'bar'),
('3', 3, 'qux'))
screen test():
vbox:
spacing 10
for a, b, c in data:
hbox:
spacing 10
text a
text '[b]' # interpolate to convert int
text c
Users browsing this forum: Duhop, Google [Bot]