有一道題: 比較兩個列表範圍,若是包含的話,返回TRUE,不然FALSE。 詳細題目以下:python
Create a function, this function receives two lists as parameters, each list indicates a scope of numbers, the function judges whether list2 is included in list1.app
Function signature:
differ_scope(list1, list2)dom
Parameters:
list1, list2 - list1 and list2 are constructed with strings,
each string indicates a number or a scope of
numbers. The number or scope are randomly, can
be overlapped. All numbers are positive.ide
E.g.
['23', '44-67', '12', '3', '20-90']
Return Values:
True - if all scopes and numbers indicated by list2 are included in list1.
False - if any scope or number in list2 is out of the range in list1.
Examples:
case1 - list1 = ['23', '44-67', '12', '3', '20-90']
list2 = ['22-34', '33', 45', '60-61']
differ_scope(list1, list2) == True
case2 - list1 = ['23', '44-67', '12', '3', '20-90']
list2 = ['22-34', '33', 45', '60-61', '100']
differ_scope(list1, list2) == Falsethis
貼上本身寫的代碼以下:(備註: python 2.7.6)spa