Each test case will generate a variable whose value is 777. Find the name of the variable.

Difficulty: introductory

Starter code:

def find_variable():
	

Solutions:
def find_variable():
    return next(k for k,v in globals().items() if v == 777)

def find_variable():
    d = globals()
    for x in d["VVV"]:
        if d[x] == 777:
            return x

def find_variable():
    for k, v in globals().items(): # k = name of variable, v = value of variable
        if v == 777:
            return k

find_variable = lambda: next(var for var, val in globals().items() if val == 777)

def find_variable():
    for k, v in globals().items():
        if v == 777:
            return k

find_variable=lambda: [k for k, v in globals().items() if v==777][0]

def find_variable():
    for i in globals():
        if eval(i) == 777:
            return i

def find_variable():
    
    for var in globals():
        if eval(var) == 777:
            return var

def find_variable():
    for k in VVV:
        if eval(k)==777:
            return k

find_variable=lambda:next(k for k in globals()if eval(k)==777)