SyntaxFix
Write A Post
Hire A Developer
Questions
This works if you want the first element, like my_list.get(0)
my_list.get(0)
>>> my_list = [1,2,3] >>> next(iter(my_list), 'fail') 1 >>> my_list = [] >>> next(iter(my_list), 'fail') 'fail'
I know it's not exactly what you asked for but it might help others.