# Testing a List inside of an Table if it is != 0 [duplicate]

I'm new to mathematica so I hope this is not a too stupid question, but I couldn't find a solution in the mathematica documentation.

I've got a normal table, initialized with "0" as entries. In the first element, I want to put a List of few numbers. I tried to build a minimalistic example as follows:

visitedNodes = Table[0,{i,1,5}]
visitedNodes[[1]] = List[1,2,3]


so visitedNodes = {{1,2,3},0,0,0,0}. Now I test:

For[i=1, i <= Length[visitedNodes], i++,
If[visitedNodes[[i]] != 0,
a = 5;   (* like: "do something" *)
Print["I'm in!"];
];
];


Since it's a "List Object", for me it's != 0, but guess I have to test it on somewhat else... but on what? :) Thank you a lot, this site also helped me already a lot =).

Edit: The question is, that the If statement for i=1 should be like "Yes, a List[1,2,3] is not equal 0, since it's the first element of visitedNodes", but it does not. So why is it like that?

-

## marked as duplicate by rm -rf♦Jan 3 at 23:29

Use visitedNodes[[i]] =!= 0
and check Unequal vs UnsameQ.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.18125194311141968, "perplexity": 1839.5898366367078}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-49/segments/1416405325961.18/warc/CC-MAIN-20141119135525-00186-ip-10-235-23-156.ec2.internal.warc.gz"}