Question

Language: Python Topic: Tuples Function name : todo_tuple Parameters : todo (list of tuples of strings),...

Language: Python

Topic: Tuples

Function name : todo_tuple
Parameters : todo (list of tuples of strings), completed (list of strings)
Returns: final_list (list)
Description : Write a function that takes in a list of tuples of strings that represents the work you have to do in each class, and a list of strings that represent the work you have already completed. Each tuple in the todo list represents the work for a single class. For this function, go through the work for class (tuple) and remove the work that you have already completed (in the completed list). Return a new list of tuples representing the modified class work without the completed work. If you finish all work for a class, do not add an empty tuple to your final list..

Notes: Your code should not allow capitalization to change the searching of the work. So for example, if “read book” is the work for one class, and “READ BOOK” is on the completed list, the work “read book” would be eligible to be removed. You will need to add the original casing of the work to your final list.

Test Cases:

>>> todoList = [(“read psyc chapter 5”, “do online survey”), (“write
meeting minutes”, “email client back”, “delete unused pictures”),
(“look over problem set”,)]
>>> completedList = [“read Psyc chapter 5”, “Look over problem set”]
>>> print(todo_tuple(todoList, completedList))
[(“do online survey”,), (“write meeting minutes”, “email client back”,
“delete unused pictures”)]
>>> todoList1 = [(“complete 1301 HW05”, “read online textbook”), (“Do
STATS Worksheet”, “solve linear program”, “”make Stochastic matrix”),
(“finish chem lab”, “write lab report”)]
>>> completedList1 = [“COMPLETE 1301 HW05”, “WRITE lab Report”]
>>> print(todo_tuple(todoList1, completedList1))
[('read online textbook',), ('Do STATS Worksheet', 'solve linear
program', 'make Stochastic matrix'), ('finish chem lab',)]
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

Code:

def todo_tuple(todo, completed):

final_list = []

for t in todo:

tp = []

for t1 in t:

exist = False

for t2 in completed:

if t1.lower()==t2.lower():

exist = True

break

if not exist:

tp.append(t1)

if tp:

final_list.append(tuple(tp))

return final_list

todoList = [("read psyc chapter 5", "do online survey"), ("write meeting minutes", "email client back", "delete unused pictures"),

("look over problem set",)]

completedList = ["read Psyc chapter 5", "Look over problem set"]

print(todo_tuple(todoList, completedList))

Add a comment
Know the answer?
Add Answer to:
Language: Python Topic: Tuples Function name : todo_tuple Parameters : todo (list of tuples of strings),...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT