I have written a very simple nested If as follows
atom = be;
If[atom == li,
lim = 5,
If[atom == be,
lim = 3,
If[atom == b,
lim = 2,
If[atom == c,
lim = 1,
If[atom == n,
lim = 0.5,
If[atom == o,
lim = 0.3,
If[atom == f,
lim = 0.1,
If[atom == ne,
lim = 0.05;
]]]]]]]];
atom
lim
but it works for atom=li namely just for first case, when I set atom=be for example it doesn't work and returns lim as unknown variable. What's wrong with it?

Whichinstead ofIf? – cvgmt Dec 05 '21 at 06:41atom == lievaluates tobe == liwhich is neitherTrueorFalse. The correct approach is to use===instead of==on comparison. – kirma Dec 05 '21 at 06:55atomlim = {li -> 5, be -> 3, b -> 2, c -> 1, n -> 0.5, o -> 0.3, f -> 0.1, ne -> 0.05}; atom = be; atom /. atomlim– kirma Dec 05 '21 at 07:03lim[atom_] := If[atom == "li", 5, If[atom == "be", 3, If[atom == "b", 2, If[atom == "c", 1, If[atom == "n", 0.5, If[atom == "o", 0.3, If[atom == "f", 0.1, If[atom == "ne", 0.05, 99] ] ] ] ] ] ] ];andlim[#] & /@ {"li", "be", "c", "n", "o", "f", "ne"}– Syed Dec 05 '21 at 07:10Doloop – Wisdom Dec 05 '21 at 07:12