I am using two For
loops. When the inner loop finishes, I don't want to print but I want to store the result from the inner loop in some variable so that I can call that variable in the future. That result will come in the form of a list.
For example, in the 1st iteration,it is returning some value, e.g. {2,4}. in the 2nd iteration,it is returning {3,4}.
But I don't want to print them every time. I want some variable to store {{2,4},{3,4}}. How to do that?
Here I am retrieving all the data except Null.
tab={{{"option1", "option3", "option4", "optio", "Null",
"Null"}, {"option2", "option5", "option6", "option7", "Null", "Null"},
{"option", "op", "Null", "Null", "Null", "Null"}}};
For[j = 1, j <= Length[tab[[1]]], j++,
For[i = 1, i <= Length[Rest[tab[[1, j]]]], i++,
If[TrueQ[(Rest[tab[[1, j]]][[i]]) == "Null"], count++, count = 0]]
Print[
Table[Rest[tab[[1, j]]][[i]], {i,1, (Length[Rest[tab[[1, j]]]] - count), 1}]] ]
For
loops exists for your problem please also explain the context of the code. $\endgroup$AppendTo[]
or the combination ofSow[]
/Reap[]
, but without something more concrete, we can't be more helpful. $\endgroup$For
loop, but I highly recommend learning about&
,@
,#
, etc.! $\endgroup$