Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![JASON LEE](https://secure.gravatar.com/avatar/798eb96d4c2cc69af1ecaf0ccb0b8be5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
JASON LEE
17,352 PointsInconsistent commands and syntax? Just memorize it ?
I noticed some of these python commands appear to be methods, some functions, and some I don't know.
For instance, given an array called my_array = [... .... ...]
...
To get the count of a content or item in an array, it is my_array.count(<content>)
This appears to be a method of the array.
To get the length of the array however, it is len(my_array)
. len
appears to be a function and the argument passed in is the array variable.
And then to delete index items from the array, it is del my_array[a:z]
Is the del
command in this case supposed to be a function, method of the array, or what ?
Just trying to make sense of how these python commands work, because otherwise I am just going to have to memorize or look up each time.
1 Answer
![Jason Larson](https://uploads.teamtreehouse.com/production/profile-photos/11651180/micro_JLarson-Crop3.jpg)
Jason Larson
8,359 PointsDisclaimer: I don't know Python. I just looked this stuff up, but I think this will answer your question. count() is a built-in method that you can use on lists/arrays (incidentally, you can use count() on strings as well). len() is a built-in function that returns the number of items in an object, or the number of characters in a string. del is a keyword used to delete objects. In Python everything is an object, so the del keyword can also be used to delete variables, lists, parts of a list, etc.
I got this information from W3 Schools: Python Reference and digging around.