I’m building an app and have setup some config fields for the user to enter text into. Basically I just want to loop through the config fields (which are empty by default) and for every one that’s filled in (ie NOT empty), add them to a list variable (arrays in Javascript, for example).
So for instance, if the user were to fill in the following configs like this:
cfg1 = ""
cfg2 = "Name"
cfg3 = ""
cfg4 = ""
cfg5 = "Location"
… I want to end up with this:
things = ["Name", "Location"]
What’s the proper syntax for looping through all the config fields and checking if they are empty or not, and if not, adding them to a new list?
Also, is there a better reference doc than this? It does talk about some details but it doesn’t really offer many examples. For instance, I looked up lists and it doesn’t show how to create a list, or how to add items. It mentions the function used but that’s it, no examples. Looking for something a little more detailed, if anything like that exists. I come from a Javascript background so I can translate concepts usually but it’s tough when you aren’t sure what the equivalent syntax is.
Thoughts?