-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5. Comparing Lists
40 lines (28 loc) · 1.17 KB
/
5. Comparing Lists
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Assignment: Compare Lists
# Write a program that compares two lists and prints a message depending on if the inputs are identical or not.
# Your program should be able to accept and compare two lists: list_one and list_two. If both lists are identical print "The lists are the same". If they are not identical print "The lists are not the same." Try the following test cases for lists one and two:
# list_one = [1,2,5,6,2]
# list_two = [1,2,5,6,2]
# list_one = [1,2,5,6,5]
# list_two = [1,2,5,6,5,3]
# list_one = [1,2,5,6,5,16]
# list_two = [1,2,5,6,5]
# list_one = ['celery','carrots','bread','milk']
# list_two = ['celery','carrots','bread','cream']
def compare_lists(list_one, list_two):
if list_one == list_two:
print "The lists are the same"
else:
print "The lists are not the same"
list_one = [1,2,5,6,2]
list_two = [1,2,5,6,2]
compare_lists(list_one, list_two)
list_one = [1,2,5,6,5]
list_two = [1,2,5,6,5,3]
compare_lists(list_one, list_two)
list_one = [1,2,5,6,5,16]
list_two = [1,2,5,6,5]
compare_lists(list_one, list_two)
list_one = ['celery','carrots','bread','milk']
list_two = ['celery','carrots','bread','cream']
compare_lists(list_one, list_two)