1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Nested for and lists in mathematica

  1. Sep 29, 2012 #1
    Hello, I'm new using Mathematica and actually can't understand what's the problem in this code

    Code (Text):

    l = {}

    For[k = 1, k < 3,
     For[j = 1, j < 3,
        t1 = RandomInteger[{1, 10}];
        t2 = RandomInteger[{1, 10}];
        t = (t1 + t2)/2;
       l = Append[l, t];
    The error I get is

    Set::write: Tag Times in Null {} is Protected. >>

    I've also tried to use an array or a table in the place of the list l, but the error persist.
    It's like if after the nested for, I couldn't append elements to the list or add elements to an array.

    Have you any idea to do what I would like to do?
    Last edited by a moderator: Sep 29, 2012
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted