When I use the code directly below, it works (indicated by the "Out:...").(adsbygoogle = window.adsbygoogle || []).push({});

But when I use it inside a loop, it acts like the tmp2 list is not the correct size:Code (Text):tmp2 = Flatten[{33, {1, 2 + j, 6}, 55}];(*Out:{33,1,2+j,6,55} *)

tmp2[[4]]; (*Out: 6 *)

This is a minimal example of a larger piece, but I don't see why it's not working.Code (Text):For[j = 0, j <= 5, j++,

tmp2 = Flatten[{33, {1, 2 + j, 6}, 55}]

Print[tmp2[[4]]]

]

(*Out: Part::partd: Part specification tmp2[[4]] is longer than depth of object. >>*)

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica: Getting part of a list, lithin a loop.

Loading...

Similar Threads for Mathematica Getting part |
---|

Mathematica Storing Mathematica output |

Mathematica Mathematica to MATLAB |

Mathematica Cannot do the integral of the Hyper-geometric function? |

Mathematica Cannot Plot This Function in Mathematica |

Mathematica While Loop in Mathematica |

**Physics Forums | Science Articles, Homework Help, Discussion**