a Collection Steps for Completion 1. Define a function named unite_lists. 2. Using a for statement, iterate through the two lists, while finding the common elements in both lists without duplicates. Snippet 6.109 shows an example output: >>> unite_lists([2,4,6,8], [3,6,9,12]) [2, 4, 6, 8, 3, 9, 12] 1 # Write your code here 2 unite_lists = [] 3 for items in a: 4 5 6 7 8 9 for numbers in b: if items == numbers: if items in c: None else: c.append(items) 10 # Test your code here 11 if __name__ == '__main__': 12 13 print (unite_lists([2,4,6,8], [3,6,9,12]))
a Collection Steps for Completion 1. Define a function named unite_lists. 2. Using a for statement, iterate through the two lists, while finding the common elements in both lists without duplicates. Snippet 6.109 shows an example output: >>> unite_lists([2,4,6,8], [3,6,9,12]) [2, 4, 6, 8, 3, 9, 12] 1 # Write your code here 2 unite_lists = [] 3 for items in a: 4 5 6 7 8 9 for numbers in b: if items == numbers: if items in c: None else: c.append(items) 10 # Test your code here 11 if __name__ == '__main__': 12 13 print (unite_lists([2,4,6,8], [3,6,9,12]))
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Although working with sets is quick and easy in Python, sometimes we might want to find the union between two lists. Create a function called unite_lists, which uses a loop to go through both lists and return common elements. Do not use the built-in set function
Expert Solution
Step 1
The source code of the program
def unite_lists(lst1, lst2):
result = []
for n in lst1 + lst2:
if n not in result:
result.append(n)
return result
if __name__ == '__main__':
print(unite_lists([2, 4, 6, 8], [3, 6, 9, 12]))
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education