len |
| len(s) |
Returns the length of an object (built-in). |
| s | a sequence (string, bytes, tuple, list, or range) or a collection (dictionary, set or frozen set) |
| REMARKS |
| * This is a built-in function. * Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set). * For the Official documentation refer to python.org |
testList = []
print(testList, 'length is', len(testList)) #= [] length is 0
testList = [1, 2, 3]
print(testList, 'length is', len(testList)) #= [1, 2, 3] length is 3
testTuple = (1, 2, 3)
print(testTuple, 'length is', len(testTuple)) #= (1, 2, 3) length is 3
testRange = range(1, 10)
print('Length of', testRange, 'is', len(testRange)) #= Length of range(1, 10) is 9
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top