How to sum numers from a list?

Hi, Kartik! :raising_hand_man:

I try this in “https://x.thunkable.com/projects/5d0ba79be8e428bff10b460e/b35d424e-a0da-4130-82c6-2c38d6725876/designer
But i dont know if i do this correctly… but nothing happens :sweat:
Sorry =/
I probably did something wrong.

You may try now :
https://x.thunkable.com/copy/908b171baa227a38c6c535f7a667d739

Make sure you read the comments.

Thanks! :wink:

1 Like

The “sum of list” block works like this. If the list contains only values ​​of the numeric type, then they will be summed up. If in the list there is at least one element of string type, then the operation of joining strings will be performed, as if all elements of the list are strings.

To sum up the string values ​​of numbers, you need to use a loop through the list with the conversion of string type numbers to numbers.

4 Likes

Thanks for helping me actech and kartik…

I just try use and i have a question… when i put de numbers ? because i think this blocks its only to list i create and can’t put numbers…
sorry, i am a very very beginner in thunkable =/

1 Like

Those “Text_Input” components is where you can enter numbers. Once they are in (accessible as “Text_Input get text”) you can copy the content to be an element in a list, or anything else you wish. I have an app where what you enter is interpreted as the colour of another component, so you have complete freedom, as long as you are consistent with the variable type and content.
In actech’s example, he put the values in a List_Viewer only to demonstrate a list that is broken down from a coma delimited string; it could have been a list that is stand alone, i.e. that is not a component in a layout.

Again, you have freedom. The art of programming is making the most effect out of the least code.

2 Likes

Hmmm i know it… the art of programming… but i don’t have the knowledge to do this… many years maybe i will have hahahaha =)

but i will try this codes to see… but its easier to me have a example than only see codes… :sweat:

Hi CBVG

I try create your label from my app here: How to sum numers from a list? - #16 by db82203608aa4b

but I did not find “roundtoplaces”

image

=(

Hello Again!

I have used the round block here in this project :
https://x.thunkable.com/copy/ef01d001e7ae4e28efba0e9863d27790

Hope it helps! :wink:

1 Like

Perhaps that is because it is a procedure I wrote, and that you can copy?

Hi again CBVG

Before anything, thanks so much for help me… and sorry for my fault of knowledge

I copy your code on my app like this but not are showing only 2 decimals

you can see here my project:
https://x.thunkable.com/projects/5d03d3be26b1a063839f8b30/dc2b7f4b-b246-4231-a757-40c730dec8b4/designer
https://x.thunkable.com/projects/5d03d3be26b1a063839f8b30/dc2b7f4b-b246-4231-a757-40c730dec8b4/blocks

You sort of have to CALL roundToPlace.
Right now, it is just there looking pretty, but not being put in action.

Each of those statements in Timer1.fires HAS to include the call to roundToPlaces.

Draw inspiration from the MOCK “do something” that was just put there as a demo.
Each line has to read something like this (only one line shown)

And in fact, since the Total_Payout and Total_Stack are ALWAYS the same, you can even make it simpler by having only one complicated equation that uses the only variable as input, and call that function (which in turns calls the function roundToPlace) instead (again only one Label_#n_CC shown):

2 Likes

YESSSSSSSSS!!!
I do it and now are all fine ;D

Thanks so much CBVG!!!
Hope i finish column 4 with no problems now :slight_smile:
Thanks thanks thanks :smiley:

2 Likes