Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

LinkedIN Community

Join our LinkedIN Community.

Counting numbers in a String

Design a function that given a text string, returns the numbers that appear in the string. For example, the string ‘a 1, a 201, and 2 ones’ contains 3 numbers: 1, 201, and 2.

>>> nums_in_string("a 1, a 201 and 2 ones")
    3
>>> nums_in_string("without numbers")
    0
>>> nums_in_string("2345543")
    1

Write pytests to test your function in an automated way.