# Converting value from light sensor into picamera shutter speed

I'm trying to make a shutter speed variable based on a reading from an adafruit TSL2561 lux sensor. Lux is converted to an Exposure value using the equation in my code below, and then an shutter speed corresponds with the calculated EV (if aperture and ISO are constant).

I've tried assigning a shutter speed variable using an if command and a list, but I keep getting an error, saying:

``````"NameError: name 'shutterspeed' is not defined.
``````

I'm very new to Python and I'm sure there is a better way of doing this, I just don't know where to start.

``````ev1 = (math.log(ch2/2.5)/math.log(2))) + 3
ss = [32000, 16000, 8000, 4000, 2000, 1000, 500, 250]

if ev1 == 8:
shutterspeed = ss[0]
if ev1 == 9:
shutterspeed = ss[1]
if ev1 == 10:
shutterspeed = ss[2]
if ev1 == 11:
shutterspeed = ss[3]
if ev1 == 12:
shutterspeed = ss[4]
if ev1 == 13:
shutterspeed = ss[5]
if ev1 == 14:
shutterspeed = ss[6]
if ev1 == 15:
shutterspeed = ss[7]
``````

``````shutterspeed = ss[ev1-8]
Assuming that you use the `ev1` variable else ware, else you might as well decrease ev1 with 8 right away and use that variable.