Complete Task 4: extract_numbers()
1) Complete the extract_numbers() function.
Mark Breakdown
2) 2 additional doctests are created
a) Doctest output is accurate (0.5 marks x 2 = 1 mark)
b) Doctest passes (0.5 marks x 2 = 1 mark)
3) Does function pass all assignment doctests provided? (0.5
marks x 4 = 2 marks)
def extract_numbers (text): 75 76 ILIRII 77 78 79 Extract all the numerical digits in a text string. Allow duplicate values as digits. Sort the digits in reverse order :param text: string data :return: a list of all the digits values of the string sorted in reverse order 80 81 82 83 84 85 86 87 88 >>> extract_numbers ("Python 15-4 is COO!_") [5, 4, 1, 0, 0] >>> extract_numbers("Sample Param") [] >>> extract_numbers ("122333") [3, 3, 3, 2, 2, 1] >>> extract_numbers ("I won 1st prize out of 482 contestants") [8, 4, 2, 1] 89 90 91 92 Add 2 more Doctests 93 94 95 E pass # code goes here. Replace 'pass' with your own python code 96
Complete Task 4: extract_numbers() 1) Complete the extract_numbers() function. Mark Breakdown 2) 2 additional doctests a
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am