Question: So I have a dictionary like the one below, however, I am trying to subtract ART[0][0] - ART[1][0] and this has to be an iteration. 

This is what I have, but it doesn't seem to work. I keep getting the error: 'KeyError: 2'

Any help would be appreciated.

```
   for i in range(1, 5): #from
      k = i
      for j in range (1, 5): #to
           if i == j:
              pass
           else:
               t = ART[j][0] - ART[i][0]
               g = ART[j][1] - ART[i][1] 

```

Sample input:

> 
> ART = {'U': (5, 6), 'E': (7, 3), 'A': (3, 3), 'O': (3, 2), 'I':
>  (1, 4)}
> 
> 
>

Answer: 
Use [`str.slice_replace`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.slice_replace.html):

```
df['B'] = df['B'].str.slice_replace(1, 3, 'AAA')

```

Sample Input:

```
   A         B
0  w   abcdefg
1  x   bbbbbbb
2  y   ccccccc
3  z  zzzzzzzz

```

Sample Output:

```
   A          B
0  w   aAAAdefg
1  x   bAAAbbbb
2  y   cAAAcccc
3  z  zAAAzzzzz

```
IMO the most straightforward solution:

```
In [7]: df
Out[7]:
        col
0   abcdefg
1   bbbbbbb
2   ccccccc
3  zzzzzzzz

In [9]: df.col = df.col.str[:1] + 'AAA' + df.col.str[4:]

In [10]: df
Out[10]:
        col
0   aAAAefg
1   bAAAbbb
2   cAAAccc
3  zAAAzzzz

```