MathsGee Answers is Zero-Rated (You do not need data to access) on: Telkom | Dimension Data | Rain | MWEB
First time here? Checkout the FAQs!
x
MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

0 like 0 dislike
57 views

What do you think is the output of the following code fragment? Is there any error in the code?

list = ['a', 'b', 'c', 'd', 'e']
print (list[10:])

 

in Data Science & Statistics by Bronze Status (8,022 points) | 57 views

1 Answer

0 like 0 dislike
The result of the above lines of code is []. There won’t be any error like an IndexError.

You should know that trying to fetch a member from the list using an index that exceeds the member count (for example, attempting to access list[10] as given in the question) would yield an IndexError. By the way, retrieving only a slice at the starting index that surpasses the no. of items in the list won’t result in an IndexError. It will just return an empty list.
by Bronze Status (8,022 points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
asked Sep 1, 2019 in Data Science & Statistics by MathsGee Diamond (74,124 points) | 44 views
0 like 0 dislike
0 answers
asked Sep 1, 2019 in Data Science & Statistics by MathsGee Diamond (74,124 points) | 526 views
0 like 0 dislike
0 answers

MathsGee provides answers to subject-specific educational questions for improved outcomes.



On MathsGee Answers, you can:


1. Ask questions
2. Answer questions
3. Comment on Answers
4. Vote on Questions and Answers
5. Donate to your favourite users

MathsGee Tools

Math Worksheet Generator

Math Algebra Solver

Trigonometry Simulations

Vectors Simulations

Matrix Arithmetic Simulations

Matrix Transformations Simulations

Quadratic Equations Simulations

Probability & Statistics Simulations

PHET Simulations

Visual Statistics

ZeroEd Search Engine

Other Tools

MathsGee ZOOM | eBook