Last active
October 20, 2021 08:17
-
-
Save naemazam/10fbad9a87b51ea3746c65875b9e0939 to your computer and use it in GitHub Desktop.
Write a function that accepts the list as a parameter. If an element appears in the list more than once, it returns true, but do not change the value of the original list. At the same time, write a program that calls this function and test results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def common_data(list1, list2): | |
result = False | |
for x in list1: | |
for y in list2: | |
if x == y: | |
result = True | |
return result | |
#azam | |
print("Enter elements of a list separated by space") | |
input_string1 = input('Enter Main list \n') | |
print("\n") | |
input_string2 = input('Enter other list \n ') | |
print("\n") | |
list1 = input_string1.split() | |
list2 = input_string2.split() | |
print("Match find: ",common_data(list1, list2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment