The problem is that 'QgsVectorLayer' objects have not attribute 'renderer'. This kind of method is for raster layers. If you want to change the transparency of **QgsVectorLayer** objects you have to use the method: 'setLayerTransparency(int)'; located in **QgsVectorLayer** class.

Next code works for these kind of objects:

    mc=iface.mapCanvas()
     
    layers=[]
    
    n = mc.layerCount()
    
    for i in range(n):
        layers.append(mc.layer(i))
    
    for layer in layers:
        layer.setLayerTransparency(90)
        layer.triggerRepaint()

I tested it in QGIS. See next image:

![enter image description here][1]

You can modify the above code for including **QgsRasterLayer** objects too.

  [1]: https://i.sstatic.net/muUq9.png