Login and get coding
Sometimes you need to capture stdout in your script. Python makes it easy with
In this Bite you will use it to get the length of a help text as returned by
get_len_help_textwhich receives a builtin. Run
helpagainst this builtin and capture its output in a variable and return its length (number of chars). If a non-builtin is passed into the function, raise a
ValueError(hint: you can use
BuiltinFunctionTypeto check this).
Here you see the function in action:>>> from helplen import get_len_help_text >>> get_len_help_text(max) 402 >>> get_len_help_text(pow) 278 >>> get_len_help_text('bogus') ... ValueError
Good luck and keep calm and code in Python!
Will you be Pythonista #196 to crack this Bite?
Resolution time: ~22 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 3.43 on a 1-10 difficulty scale.
» You can do it! 😌