Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
hamza_b23
Group Title
what does this function mean a[0] and a[0:1] what does that colon mean
 2 years ago
 2 years ago
hamza_b23 Group Title
what does this function mean a[0] and a[0:1] what does that colon mean
 2 years ago
 2 years ago

This Question is Closed

agdgdgdgwngo Group TitleBest ResponseYou've already chosen the best response.0
In python, the colon is the slicing operator, so it returns the elements between 0 and 1, including the element in index 0 and excluding the element in 1
 2 years ago

shandelman Group TitleBest ResponseYou've already chosen the best response.2
a[0] returns the first element of the list a (we start counting at 0). a[0:1] returns all the elements in a from 0 up to but not including 1. Let's say I had a list x = [5,10,15,20,25]. x[1] would return 10. x[4] would return 25 x[5] would return an error, because x[5] is the sixth element, and there isn't one. x[2:4] would return [15,20]...it returns element 2, element 3, but not element 4.
 2 years ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.