# E-2 MCS 260 Fri 11 July 2014 : fourth question on part two of midterm
"""
Write a Python script that prompts the user for a list of items
and a tuple of integers.  The length of the list must be the same
as the length of the tuple.  The list may contain objects of any type,
whereas the integers in the tuple must between 0 and the length
of the list minus one.

The script computes a new list, placing the objects in the given list
as defined by the tuple as follows:
the k-th element in the given list is placed at the position
equal to the value of the k-th integer in the tuple.

Two examples of running the script q.py
at the command prompt $ are below:

$ python q.py
Give a list : ['a', 'b', 'c']
Give a tuple of positions : (2, 1, 0)
The new list : ['c', 'b', 'a']
$ python q.py
Give a list : ['a', 'b', 'c']
Give a tuple of positions : (1, 2, 0)
The new list : ['c', 'a', 'b']

Write code for your Python script below.
"""
LRAW = raw_input('Give a list : ')
TRAW = raw_input('Give a tuple of positions : ')
L = eval(LRAW)
T = eval(TRAW)
from copy import deepcopy
R = deepcopy(L)
for i in range(len(L)):
    R[T[i]] = L[i]
print 'the new list :', R
