[Solved] How do I add items to the beginning of a list?

Hi, Thunkable. I seem to be having an issue with lists on my application. The application has one screen with one label in the center. I think that the following code should set the label to say “3”, but the application just freezes at this point, and refuses to do anything else.


Is there anything I am doing wrong? Thank you!

2 Likes

Hi, @rongill100percentbho! :wave:

Welcome to our Community! :tada: :tada:


Yep. There are two things you are doing wrong -

  • First, you are initializing the variable at numerical type.
    And you are treating it as a list - i.e, you are inserting an item in a numerical variable; not in a list.
  • Second, you are setting the label’s text to a list. Labels can have text source only, not list(s).

So, in order to solve this, you just need to do this - :arrow_down:

image
:arrow_right: (This will set the label’s text to a number, i.e. 3.) :arrow_left:


Hope I helped you! :smile:
Thanks! :blush:

3 Likes

Hi,

  • Second, you are setting the label’s text to a list. Labels can have text source only, not list(s).

You are mistaken, Labels.text may take as a source list and display it on the screen. This is possible due to the fact that the list is converted to a string data type. For this reason, the text property of any component will be output and the number, and logical values ​​without problems.

4 Likes

Hi @rongill100percentbho

Just to expand on Kartik’s point a little:

I took a quick look and found that this won’t work because the myList variable is a number and not a list.

However, something like this will work because we’re just adding an extra list item to the end of the list:

Finally, if you don’t happen to know what the list contents will be you can always use the empty list block to create a list that has no contents.

3 Likes