Python Inbuilt Functions
Python Inbuilt Functions
11.Count
s = "mississippi"
print(s.count("i", 2, 8)) # Output: 2 (counts "i" from index 2 to 8)
ARRAY METHODS
4. pop() → Removes and returns the last element (or at a given index)
nums = [1, 2, 3]
nums.pop()
print(nums) # Output: [1, 2]
nums = [1, 2, 3]
nums.reverse()
print(nums) # Output: [3, 2, 1]
hashmap = defaultdict(int)
hashmap["a"] += 1
print(hashmap["a"]) # Output: 1
print(hashmap["b"]) # Output: 0 (default int value)