1 | initial version |
def remove_less_than_two_digits(arr): return [num for num in arr if len(str(num)) >= 2]
Here, the function takes an array arr as input and returns a new list that only contains elements with two or more digits. It does this by iterating through each element in the input array, converting it to a string using str(num), and then checking if its length is greater than or equal to 2 using len(str(num)) >= 2. If the element meets this criteria, it is added to the new list using a list comprehension.
2 | No.2 Revision |
def remove_less_than_two_digits(arr):
return [num for num in arr if len(str(num)) >= 2]
Here, the function takes an array arr as input and returns a new list that only contains elements with two or more digits. It does this by iterating through each element in the input array, converting it to a string using str(num), and then checking if its length is greater than or equal to 2 using len(str(num)) >= 2. If the element meets this criteria, it is added to the new list using a list comprehension.