#main
A = [5,2,9,6,3]
B = [2,4,3,9,7,1,6,5]
flag = isList1InList2(A, B) if flag:
print "The list", A, "is contained in the list", B else:
print "The list", A, "is not contained in the list", B
Implement the function named isList1InList2 that takes two list arguments and returns True if and only if each element of the first list argument are found in the second list argument; otherwise it returns False.
Remark: You are NOT allowed to use the in operator or any other built in function when you write this function. Instead, if you wish, you can use the function you wrote in Part A.
For the lists shown in the main program, your function must return True because each element of list A is found in list B.
-
A given List is known as Palindrome List if the reverse of the List contains the same elements in the same order of the original List. For example the List of integers [2, 5, 0, 3, 3, 0, 5, 2] is a Palindrome because the reverse of the List which is [2, 5, 0, 3, 3, 0, 5, 2] contains the same elements in the same order as the given List. However the List [1, 2, '2', 1] is not Palindrome because its reverse which is [1, '2', 2, 1] does not contain the same elements in the same order as the given List.
Write a Python function named isPalindrome that takes a List as argument and returns True if the argument is a Palindrome List; otherwise it returns False. You don't need to write the main program; just write the function. If you would like to test your function, then it is ok to write the main program too but you will not get any mark for the main program.
-
Given your function in question #7 above, what is the output of the following code: a=[]
b = [5,2,9,6,3]
print isList1InList2(a,b)
-
Given your function in question #7 above, what is the output of the following code:
a=[]
b=[]
print isList1InList2(a,b)
-
Given your function in question #7 above, what is the output of the following code: a = [5,2,9,6,3]
b=[]