update list based on other values Basically I have a 2d list containing movies. Movies are specified by name, version and description. For example

['Jaws', 1, 'Movie about sharks']  - where Jaws = name, 1 = version and Movie about sharks = description.

My result is a dictionary which contains a map between name and description. But name should be updated to contain the version for e.g 

['Jaws', 2, 'Movie about more sharks'] - should now be : 

{'JawsV2': 'Movie about more sharks'}

Is there a more pythonic way to do this?

def movie_version_map():
    movies =  [['Jaws', 1, 'Movie about sharks'], 
               ['Jaws', 2, 'Movie about more sharks'], 
               ['HarryPotter', 1, 'Movie about magic'], 
               ['HarryPotter', 4, 'Movie about more magic']]
    for movie in movies:
        if movie[1] != 1:
            movie[0] = ''.join([movie[0], 'V',str(movie[1])])

    newversion = dict([(movie[0],movie[2]) for movie in movies])
    return newversion


Output

{'Jaws': 'Movie about sharks', 'HarryPotter': 'Movie about magic', 'HarryPotterV4': 'Movie about more magic', 'JawsV2': 'Movie about more sharks'}
A simple dict comprehension and use of str.format() will do the job here:

&gt;&gt;&gt; {"{}V{}".format(name, version): description 
     for name, version, description in movies}
{'HarryPotterV1': 'Movie about magic', 
 'HarryPotterV4': 'Movie about more magic', 
 'JawsV1': 'Movie about sharks', 
 'JawsV2': 'Movie about more sharks'}


Or, in very old versions of Python where dict comprehensions don't exist, simple replace with dict() and a generator expression - e.g: dict(... for ... in moves).

Note that if this is just because you want to have the data as keys, you don't need to turn them into a string, a tuple can be a key too:

&gt;&gt;&gt; {(name, version): description 
     for name, version, description in movies}
{('Jaws', 1): 'Movie about sharks', 
 ('HarryPotter', 4): 'Movie about more magic', 
 ('Jaws', 2): 'Movie about more sharks', 
 ('HarryPotter', 1): 'Movie about magic'}


This would be more appropriate where you don't need the strings, as it means you don't have to parse stuff out or create strings for keys, and makes the data easier to manipulate.