Added week 9
This commit is contained in:
36
week9/ex4.py
Normal file
36
week9/ex4.py
Normal file
@@ -0,0 +1,36 @@
|
||||
def is_lists_exactly_same(list1,list2,*args):
|
||||
if not args:
|
||||
return list1 == list2
|
||||
'''
|
||||
rtv = len(list1) == len(list2)
|
||||
if not rtv :return False
|
||||
for i in range(len(list1)):rtv = rtv and (list1[i] == list2[i])
|
||||
return rtv
|
||||
'''
|
||||
else:
|
||||
ls = [list1,list2,*args]
|
||||
rtv = True
|
||||
for i in range(len(ls)-1):
|
||||
rtv = rtv and ls[1]==ls[i+1]
|
||||
return rtv
|
||||
|
||||
|
||||
def main():
|
||||
print('==Exercise 4==')
|
||||
|
||||
l1 = [1,2,3,4,5]
|
||||
l2 = [1,2,3,4,5]
|
||||
l3 = [1,4,5,2,3]
|
||||
l4 = [1,2,3,4,5]
|
||||
l5 = [1,2,3,4,5]
|
||||
|
||||
print(f"{l1},{l3}=>{is_lists_exactly_same(l1,l3)}")
|
||||
print(f"{l2},{l4}=>{is_lists_exactly_same(l2,l4)}")
|
||||
print(f"{l1},{l2},{l3}=>{is_lists_exactly_same(l1,l2,l3)}")
|
||||
print(f"{l1},{l4},{l5}=>{is_lists_exactly_same(l1,l4,l5)}")
|
||||
|
||||
print('==End Of Ex4==')
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user