Write a function diff(list1, list2). When called with list arguments list1 and list2, it should return a new list dlist

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a function diff(list1, list2). When called with list arguments list1 and list2, it should return a new list dlist

Post by answerhappygod »

Write A Function Diff List1 List2 When Called With List Arguments List1 And List2 It Should Return A New List Dlist 1
Write A Function Diff List1 List2 When Called With List Arguments List1 And List2 It Should Return A New List Dlist 1 (69.2 KiB) Viewed 42 times
Write a function diff(list1, list2). When called with list arguments list1 and list2, it should return a new list dlist without duplicates, with dlist containing each top-level element of list1 that does NOT Occur as a top-level element in list2. Also, dlist should contain each top-level element of list2 that does NOT occur as a top- level element in list1. Use == to do your comparisons. Define a main() function which reads two lists list1 and list2 from the user: use the eval() function to convert each of these inputs into actual lists. Then call diff(list1, list2) and print the returned result. Example: diff([1,4,2,1,3,2],[1,4,5]) should return [2,3,5), since 2 and 3 occur in the first list, but not in the second, and 5 occurs only in the second . Note that although 2 occurs twice in the first list, it appears only once in the returned list: no duplicates should be returned.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply