Renamer script for Vertex Groups (.L to .R)

I don’t know if this is the right place for requests, but I’ve now wasted an entire Saturday on Google and Blenderartists looking to find a script that flips vertex group names, and I haven’t been able to find anything at all.
So can some kind soul please write down those five lines of python code for me right here?

The script should be able to find all “.L” in the list of vertex groups of the currently selected object.
That includes names like “finger.L.002” where the .L is not at the very end of the name.
And then flip them, replacing the “.L” with “.R”. That is all.

I tried to do this myself by modifying a script that I found online.

import bpy

obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='OBJECT',toggle=True)
for g in obj.vertex_groups:
    print(g.name)
    g.name.replace(".L", ".R")

But since I don’t know the first thing about Blender scripting it did of course not work.

g.name = g.name.replace(".L", “.R”)

Thanks very much.