Quick assignment: Lists For this assignment, you must create and make use of lists and master the basic skills in() and append(). 1. Create a new list. The list should be called "colour_list". The list should contain the following items: Red, Blue, Purple, Green, Orange, Beige, Peach. 2. Create another list now, which is called "fruit_list". This list should contain: Apple, Banana, Orange, Prune, Pineapple Peach. 3. Print both lists 4. Now create a new EMPTY list and call it "fruits_that_are_colours" 5. Iterate (using a for loop) through the first list, and check whether it is in the second list. if it is, add it to the third list with append() 6. Now print the list of fruits that are colours. Done. For a little extra challenge (optional), make use of functions to make the code slicker. Try to keep your main code as only calls to functions. Take note that lists created INSIDE functions will not "exist" outside of the functions unless you define them as global variables. However, if you define a list outside a function, it can be modified outside
Quick assignment: Lists For this assignment, you must create and make use of lists and master the basic skills in() and append(). 1. Create a new list. The list should be called "colour_list". The list should contain the following items: Red, Blue, Purple, Green, Orange, Beige, Peach. 2. Create another list now, which is called "fruit_list". This list should contain: Apple, Banana, Orange, Prune, Pineapple Peach. 3. Print both lists 4. Now create a new EMPTY list and call it "fruits_that_are_colours" 5. Iterate (using a for loop) through the first list, and check whether it is in the second list. if it is, add it to the third list with append() 6. Now print the list of fruits that are colours. Done. For a little extra challenge (optional), make use of functions to make the code slicker. Try to keep your main code as only calls to functions. Take note that lists created INSIDE functions will not "exist" outside of the functions unless you define them as global variables. However, if you define a list outside a function, it can be modified outside
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 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
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT