Create a function named double_index that has two parameters, a list named lst and a single number as index .
The function should return a new list where all elements are the same as in lst except for the element at index , which should be double the value of the element at index of lst .
If index is not a valid index, the function should return the original list.
Those are already explanations in English, so what are you asking for? Better if you ask for specific information and/or tell what you don’t understand, than to ask for something to be more and better which doesn’t say what is insufficient about what you already have.
Then, what you misunderstand is what a function does.
A function accepts some values, does some operations on it, and produces an output value.
In other words, a big part of what a function does is to delay evaluation until those values do exist.
So when you ask how it runs without inputs being defined - it doesn’t. All a function definition does is to say what happens when the input does arrive.
If you want to learn about how a function operates, then don’t put a bunch of complicated code in it to distract you.
Use something simple instead. Like addition.
def f(a, b):
return a + b
This is the same situation, is it not? But by eliminating code that isn’t relevant to what you’re asking, suddenly it’s a whole lot simpler, you might even already understand everything going on here at this point. All that remains then, is to treat your other function the same way.
Then I would argue that you should leverage what you know to bring yourself from the starting state to the desired state.
If you click the solution button then what’s the point? It’ll only get worse as you continue if you have no solid ground to stand on.
Most programming tasks are solved by combining many small operations into increasingly powerful/useful operations. Most tasks boil down to not much other than if-statements and loops. So if you know those, then you can solve many other tasks as well.
up to this point I did everything by myself except the random game task because that was too complex for the education the site gave me which is something that should be looked at…
it expects me to google everything myself and find solutions on other sites rather than teaching it and explaining
rather dissatisfied as it is 32 pounds a month
For most problems you will want to start by considering how the information needs to be processed. For example, if something is about a list, then you might write down a list on a piece of paper and process that list manually, analyzing what you do, break down into smaller steps. You may need to break down those steps into smaller steps and so on, until the parts are small enough that they match things you know how to use in code.
There’s too much to know to keep it all in your head. This is what you should do. Not to obtain finished solutions, but to find out how to carry out various operations so that you can then leverage them in your own code.
Not sure what that has to do with programming. Might have something to do with codecademy the company, but that isn’t me.
right,
can you answer if lst, start, end have to be defined or not?
what if theres:
numbers = [1, 5, 3, 2, 6]
items = [handle, vernier, ladder, knife]
will numbers automatically become lst1 and items become lst2?
is start automatically 1 for numbers and handle for items?
is end automatically 6 for numbers and knife for items?
thanks
where do a and b come from?
what is f?
how is f used?
have you used any other functions? how does that look like? how does that relate to f, a, b?
If f is a function, then what can you do with f, what can you do with a function?
Usually what you would do with a function is to call it. What does that involve?