''' TODO - implement function to return the sum of integer elements that meet the following criteria: - Occur only once in the list - Have no repeating digits (for ex: 123 would be included, but 112 would not) ''' def unique_sum(number_list): # WRITE CODE HERE return #--------------------NO CHANGES REQUIRED BELOW--------------------------------------- test_cases, results = [], [] test_cases.append([1, 21, 33, 4, 4, 4, 4, 5, 5]) results.append(22) test_cases.append([414, 583, 770, 51, 414, 853]) results.append(1487) test_cases.append([9, 9, 131, 19, 113, 19, 133]) results.append(0) test_cases.append([16, 0, 11, 4, 8, -16, 0, -16057, 16, 4, 16050]) results.append(-16065) test_cases.append([5555, 1000, 1973, 12635, -10, 134, 12]) results.append(14744) test_cases.append([]) results.append(0) for test_case, result in zip(test_cases, results): assert unique_sum(test_case) == result, " With test case {} got {}, should be {}".format(test_case, unique_sum(test_case), result) print("every test passed")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question