oganozturk
(Nagon Stewart)
1
I’m trying to get a list output, but I get integer results.
Is there a way to convert integers to list?
Here is my code:
list = {12, 37, 44, 96};
list2 = IntegerDigits[list];
Do[
list3 = Total[list2[[i]]];
Print[list3];
, {i, 1, Length[list]}]
oganozturk
(Nagon Stewart)
3
Yes, I meant that, thank you.
You can find this trick in Documentation of Do.
list = {12, 37, 44, 96};
list2 = IntegerDigits[list];
Reap[Do[list3 = Total[list2[[i]]];
Sow[list3];, {i, 1, Length[list]}]][[2, 1]]
(* {3, 10, 8, 15} *)
list = {12, 37, 44, 96};
list2 = IntegerDigits[list];
t = {}; Do[list3 = Total[list2[[i]]];
AppendTo[t, list3];, {i, 1, Length[list]}]; t
(* {3, 10, 8, 15} *)
oganozturk
(Nagon Stewart)
5
Thank you Mariusz, This trick helped.