Language is Python 3.6 Function Name: unique_lists Parameters: list1, list2 Retu
ID: 3870577 • Letter: L
Question
Language is Python 3.6
Function Name: unique_lists Parameters: list1, list2 Return Value: The modified list1 Description: Write a function that takes in two lists. If an element in list2 is not in list1, append that element to list1. If an element in list2 is already in list1, remove that element from list1. Return the updated list1 Test Cases: >>> newList -uniquelists ([6, "butterfly", "waffle", 191, [True "shirt", 8, "waffle", 6, "computer"]) >>> print (newList) 'butterfly', 19, True, 'shirt', 8, 'computer >newList-unique_lists(["water", "sand", "beach", 14], [False, "earring", "smile", 17]) >>> print(newList) ['water', 'sand', 'beach', 14, False, 'earring', 'smile', 17] Function Name: process_string Parameters: aStr, aNum (int) Return value: a list of ints Description: Write a function that accepts a string of characters, filters out all non- number characters from the string, and returns a list of the numbers in the string that are a factor of aNum. NOTE: You can also ignore all zeroes (0) in the string, as 0 is not a factor of any number. Test Cases: >>> process_string("jahfig234thdajgögri9t2832488radga", 12) [2, 3, 4, 2, 3, 2, 4] >>process string( "aoweh102935igalhfda03191ifwl", 7) >>> process-string("!@t^%&*&SXA;$^^$%$#%"&*(){}|Explanation / Answer
function unique_lists:
def unique_lists(a, b):
a=set(a)
b=set(b)
c=a-b
d=b-a
ans = c.union(d)
ans = list(ans)
return ans
function process_string:
def process_string(aStr,aNum):
listNum = []
for i in range(len(aStr)):
if aStr[i]>='1' and aStr[i]<='9':
listNum.append(int(aStr[i]))
ans = []
for i in listNum:
if aNum % i == 0:
ans.append(i)
return ans
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.