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


To add value to MathsGee Answers, you can now support those users that are helping you with their answers, questions, votes and comments. Simply click on their name and DONATE an amount to say "Thank you"



Network: Global | Joburg Libraries | MOOCs | StartUpTribe | Zim Invest | Donate

MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

0 like 0 dislike
50 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 by Bronze Status (5,270 points) | 50 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 (5,270 points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
asked Sep 1, 2019 in Data Science by MathsGee Diamond (64,816 points) | 44 views
0 like 0 dislike
0 answers
asked Sep 1, 2019 in Data Science by MathsGee Diamond (64,816 points) | 498 views
0 like 0 dislike
0 answers

MathsGee Answers is a global, STEM-focused Q&A platform where you can ask people from all over the world educational questions for improved outcomes.



MathsGee Supporting City of Joburg

Registered Members Online
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

Interactive Courseware

ZeroEd Search Engine

Article Rewriter Tool

Word Counter Tool

Other Tools

Big Blue Button | STEM Gender Equality | ZOOM | Slack | eBook