why does counter outruns list length

Solution for why does counter outruns list length
is Given Below:

longuer=int(input("input list lengh: "))
l1=list(range(longuer))
print('list lengh: '+str(longuer))
i=0
while i<len(l1):
    a=int(input("give number: "))
    l1.append(a)
    print("i="+str(i))
    i+=1
print(l1)

code output output

I don’t understand why ‘i’ outruns the length of the list ?
would love a good explanation with a fix for this please

longuer=int(input("input list lengh: "))
l1=[]
print('list lengh: '+str(longuer))
i=0
while i<longuer:
    a=int(input("give number: "))
    l1.append(a)
    print("i="+str(i))
    i+=1
print(l1)