5 kyu
Check the status of the generator expression
136Chris_Rands
Description:
My third kata, write a function check_generator
that examines the status of a Python generator expression gen
and returns 'Created'
, 'Started'
or 'Finished'
. For example:
gen = (i for i in range(1))
>>> returns 'Created'
(the generator has been initiated)
gen = (i for i in range(1)); next(gen, None)
>>> returns 'Started'
(the generator has yielded a value)
gen = (i for i in range(1)); next(gen, None); next(gen, None)
>>> returns 'Finished'
(the generator has been exhuasted)
For an introduction to Python generators, read: https://wiki.python.org/moin/Generators.
Please do vote and rank the kata, and provide any feedback.
Hint: you can solve this if you know the right module to use.
Fundamentals
Similar Kata:
Stats:
Created | Dec 24, 2016 |
Published | Dec 24, 2016 |
Warriors Trained | 481 |
Total Skips | 64 |
Total Code Submissions | 370 |
Total Times Completed | 136 |
Python Completions | 136 |
Total Stars | 14 |
% of votes with a positive feedback rating | 90% of 45 |
Total "Very Satisfied" Votes | 37 |
Total "Somewhat Satisfied" Votes | 7 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 8 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |