-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrial4.py
23 lines (19 loc) · 831 Bytes
/
trial4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
L1 = [1, 'b', 1, 'c', 'c', 1]
L2 = ['c', 1, 'b', 1, 1, 'c']
def isPermutation(list1,list2):
if len(list1) != len(list2):
return False; #two list does not have same length so impossible being permutation of each other
for i in range(0, len(list1)):
if list1.count(list1[i]) != list2.count(list1[i]):
return False
def is_list_permutation(list1,list2):
if (isPermutation(list1,list2) == False): #use the above method isPermutation to check if they are permutation of each other
return False #if not return false
elif not list1:
return (None, None, None)
else:
mostOccurItem = max(set(list1), key=list1.count)
numberOfTimes = list1.count(mostOccurItem)
theType = type(mostOccurItem)
return (mostOccurItem, numberOfTimes, theType)
print(is_list_permutation(L1,L2))