it keeps giving me this error can you tell me why. I can't find the answer
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
x = len(List)
for i in range(x):
if List[i] == target:
return i
elif List[i] > target:
return List[i-1]
TypeError: object of type '_SpecialGenericAlias' has no len()
You're not checking the length of nums, you're trying to check the lenght of List which is just an alias.
Replace x = len(List)
with x = len(nums)