def test_tokens(tokens): print(" [x] Testing {0} tokens to be valid...".format(len(tokens))) good_tokens = [] for token in tokens: if token == '': continue print(" [x] Testing token {0}...".format(token[:13] + '*****************' + token[:30])) api = API(token) try: response = api.execute(code='return "itworks";') print(response) if response == 'itworks': good_tokens.append(token) except: continue return good_tokens