Help

So that’s a new question, then?

This is out of the way?

the solution as whole:

#Write your function here
def remove_middle(lst, start, end):
return lst[:start] + lst[end+1:]

#Uncomment the line below when your function is done
print(remove_middle([4, 8, 15, 16, 23, 42], 1, 3))

and prints [4, 23, 42]

same question just with example

I don’t understand what the question is.

What seems to be a different question, of: why does <all this code> produce this result
That’s going to be something you answer by understanding what each individual operation does.
So you’d have to start with the first operation, go learn it, move on to the next, and so on, until you can account for all steps that were taken.

But, I think you should be approaching it from the other end: namely, reading the exercise instructions, understanding the task, thinking about what actions you want to be carrying out to fullfil that task, and then implement those actions one at a time until you’ve written them all.

because the steps described by the instructions were carried out. right?

the solution as whole:

#Write your function here
def remove_middle(lst, start, end):
return lst[:start] + lst[end+1:]

#Uncomment the line below when your function is done
print(remove_middle([4, 8, 15, 16, 23, 42], 1, 3))

and prints [4, 23, 42]

why is this happening

Doesn’t that already explain why that is the result? You have a function matching this^ description. Isn’t that the output you would expect when providing it with that input?

maybe it’s my english…
could you word this another way please? it doesn’t make any sense

Word what another way?
The instructions?

That would be a third question, and the first thing you would do when approaching the exercise, to understand what it’s asking for. There would be absolutely no point at all in trying to write code much less view the solution if you haven’t first figured out what problem there is to solve.

But no, I can’t explain more-better.

allright, explain what lst, start and end is in the function

Where do a and b come from in f?

Go google for just about any programming tutorial, find its chapter on functions, and read.

Like I’ve been saying about other things, break them down into pieces, figure out the individual pieces, and then come back to the whole. In this case your piece is: functions, what at all are they, how do I make them, how do they operate, how can they be used. So that would be something you can grab a programming tutorial off google, look up the chapter on functions, and start reading. Doesn’t even matter which programming language the tutorial is, just about all languages have functions.

Perhaps the more important part here is that this is something you will never stop doing. Breaking things apart, solving the pieces, coming back to the whole. Whether it’s code or things you need to learn, or things you need to do.

i input it
(has to be 20 chr reply)

So if you can tell me where a and be come from then what’s different about the parameters of your other function?
They’re both functions aren’t they? And as far as the anatomy of function goes, you’re talking about the same part of f as of your own function.

how does
lst[:start] + lst[end+1:]
become 23 and 42?

That’s one expression, it does not become two values, it becomes one value.
If you mean to ask where lst start and end come from, then you already answered that.

that’s what you do with functions.

maybe someone else has an explanation instead of playing guessing games?
thanks

I get it now
(20 characters)

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.