Question
I have to create your own example of a function that modifies a list passed in as an argument. Describe what your function does in
I have to "create your own example of a function that modifies a list passed in as an argument. Describe what your function does in terms of arguments, parameters, objects, and references." (in PYTHON 3)
So, I want to make a list of "declarations" and then take another list of "exclamations" and cycle thru both lists to attach each element of the "exclamations" list onto each element of the "declarations" list, in order.
I can't figure out how to make it work.
This is what I have:
#create a list of 3 string values and assign it to an object called declarations declarations = ["Cats are cool", "Dogs are awesome", "Birds are radical"] #create a second list exclamations = ["heck yeah!", "ain't that the truth!", "NOT!" ] #modify the declarations list by traversing it sequentially and adding the exclamations list, in order, to the elements in the #declarations list def modify_list(declarations): for i in declarations: while len(exclamations)
modify_list(declarations)
it won't allow me to show my indentations, so here's a pic:
That doesn't work, obviously. How can I make it work?
#create a list of 3 string values and assign it to an object called declarations declarations ["Cats are cool", "Dogs are awesome " , "Birds are radical"] #create a second list exclamations["heck yeah!", "ain't that the truth!", "NOT!" #modify the declarations list by traversing it sequentially and adding the exclamations list, in order, to the elements in the declarations list def modify list (declarations) for i in declarations: while len (exclamations) -len (declarations) : for i in exclamations: suffix 0 suffix = suffix + i return sufrix whole-phrase declarations.append(exclamations) print (whole phrase) modify list (declarations)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started