List symbol unrecognized

I can’t seem to find information on the values in the list notation.
.
Example: [0:-4]

I created a code and tried to run it to answer the question, but I’m doing something wrong in the code.
I know there are two separate values separated by a colon and square brackets.
I’m thinking in terms of a list with the last five [0,1,2,3,4,]
And [-5,-4,-3,-2,-1]

I’m looking on YuoTube and everywhere to get the answer?

Thank for any help:)

On the python interpreter, write this dummy code:

employees = [‘john’, ‘james’,‘don’, ‘dan’, ‘bob’,‘a’,‘b’,‘c’,‘d’,‘e’]

Here, ‘a’,‘b’,‘c’,‘d’,‘e’ are the five management employees, and john, james, don, dan, and bob are non-management employees.

now, type the first choice in the interpreter: print employees[:-5]

what do you see? is this similar to what they want you to display?
now, type the second choice in the interpreter: print employees[1:-5]
what do you see?
do this for the other choices. figure out what’s happening.

The easiest way to figure these out is with the Python REPL (Read Execute Print Loop). Just type:

$ python3
Python 3.6.3 (default, Dec  7 2017, 00:40:34)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Then right there you can type up and large or small list to play with:

>>> employees = list(range(0,199))
>>> employees[0:-5]

Problem is, this question is very vague. You may have to get clarification.

1 Like

Thank’s Zed,
This is the the code that I want to use. [1:-4] and [0:-4] is what I want to display. It list all the employees and slices the last 6, ranging from 1 to 194. These have to be the correct answer even though it slices the last 6. I’m assuming a extra employee in the list is zero, slicing six employees instead of five?

Thank you!

I suppose so, but that question is just weird. Where did you get it?

I got it from the exam. I’ve failed the exam twice, however I am getting better with my scores. The exam is designed for programmers with some experience. I pass all the exercise with my school but the exam is as I have said. I work on Python all day long, and I am getting better with understanding how to answer these questions. I wont give up and it seems that things are starting to clear up. Today I’m exercise 40 in the book Python 3.

Thank you!

Do you have a link to this exam?

No I do not have a link to an exam, but it was one of the questions.

So, my advice is that you spend some time focusing on becoming better at just general Python programming skill. It seems, from your questions, that you’re being asked these questions but haven’t spent much time studying python and writing python code. Have you gone through my book at all? How far did you get?

Hi Zed,
I’m glad that you have asked the questions that you have. I’m in a situation that I must keep learning before the next exam. March 6, 2018. I’m on exercise 43 with your book. The tasks that your asking me to do takes some time to complete. I have spent this whole week studying with Lynda.com where they have broken each subject down to the basics and I have been able to understand a lot. My courses at Learnkey Blue Ocean did not get into the details of list and explaining the [start: stop: steps].
Again they do explain that the exam is for experience Python programmers, well that’s what I have to deal with. I am spending my whole day working and learning from other resources. Tomorrow I will go back to through my school courses again. I have put too much time into this give up know. I can understand things better today. I’m trying to get as much in as possible before the next exam. Any other information you have I will use.
Thank you

Correction, employees = list(range(0,200)) will slice the last five employees. Thanks for your help!

I wish this was painting, then it would be easy. I’ve been to three colleges for art and a oil painting major.

Well, I’m not saying give up, I’m saying focus on just one learning resource so that you establish the basics, rather than running around to 10 different resources all scatter brained and rushing. Spending 8 hours doing just my two books would get you farther than 1 hour each on 8 different books.

Okay, will do. I have your book Python 3 The Hard Way. I would like to know where to find your other book? I have also taken your advice from ex43 about going back to review other exercises again.

Thank You!

The followup book to LPy3THW is https://learncodethehardway.org/more-python-book/ which is a lot of work, but staged in small chunks so that you’re not overwhelmed. Just keep chipping away at it until you get it. I have live students now who are going through it and it’s about a 6 month to 1 year book but when you’re done you’ve learned what I consider to be a light overview of all the major topics.