13 challenges match these filters
add_tag(tags, new_tag) adds a tag to a post's tag list and returns the updated list, so add_tag(["python"], "debugging") returns ["python", "debugging"].
Other
sorted_names(names) should return the names in alphabetical order, so sorted_names(["b","a"]) returns ["a","b"].
Other
last_char(text) should return the final character, so last_char("hello") returns "o".
Off-by-one
middle_item(items) should return the middle element, so middle_item([1, 2, 3]) returns 2.
Type error
attempts_until_success(n) retries until the nth attempt succeeds and returns the number of tries, so attempts_until_success(3) returns 3.
Infinite loop
last_even(nums) should return the last even number, or -1 if there are none. last_even([1, 3]) should return -1.
Scope error
shout(text) should return the text in uppercase, so "hello" becomes "HELLO".
Other
count_words(text) should count the words in a string, however much whitespace separates them.
Logic error
average(nums) should return the mean of a list of numbers, including any fractional part.
Type error
get_setting(config, key) should return the value for a key, or the string "default" when that key isn't present.
Null / Undefined
can_checkout(cart_total, has_valid_payment) should return True only when the cart has items AND payment is valid.
Logic error
format_price(amount) should return the amount formatted as a price string, e.g. format_price(5) -> "$5".
Type error
sum_range(n) should return the sum of all integers from 1 to n, inclusive.
Off-by-one