title: Assigning Values to an Array with for Loop Python
body: <p>I'm trying to assign the values of a string to different array indexes </p>
  
  <p>but I'm getting an error called "list assignment out of range"</p>
  
  <pre><code>uuidVal = ""
  distVal = ""
  uuidArray = []
  distArray = []
  
  for i in range(len(returnedList)):
       for beacon in returnedList:
              uuidVal= uuidVal+beacon[:+2]
              uuidArray[i]= uuidVal
              distVal= distVal+beacon[-2:]
              distArray[i]= distVal
              uuidVal=""
              disVal=""
  </code></pre>
  
  <p>I tried using </p>
  
  <pre><code>distArray[i].append(distVal)
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>distArray[i]= distVal
  </code></pre>
  
  <p>but it gave an error called "list index out of range"</p>
  
  <p>Using </p>
  
  <pre><code>distArray.append(distVal)
  </code></pre>
  
  <p>made it work with no error but the outcome was wrong</p>
  
  <p>because it keep concatenating the new assigned value with old values in the next index</p>
  
  <p><strong>How it should work:</strong></p>
  
  <p>returnedList[<strong>'52:33:42:40:94:10:19, -60'</strong>, <strong>'22:34:42:24:89:70:89, -90'</strong>, <strong>'87:77:98:54:81:23:71, -81'</strong>]</p>
  
  <p>with each iteration it assign the first to char to <strong>uuidVal</strong> (ex: 52, 22, 87)
  and the last two char to <strong>distVal</strong> (ex: 60, 90, 81)</p>
  
  <p>at the end <strong>uuidArray</strong> should have these values <strong>[52, 22, 87]</strong></p>
  
  <p>and <strong>distArray</strong> should have these values <strong>[60, 90, 81]</strong></p>
  
  <p><strong>Note:</strong> using <strong>.append</strong> concatenate the values, for example if used with <strong>distArray</strong> like <strong>distArray.append(distVal)</strong> the values will be like this <strong>[60, 6090, 609081]</strong></p>