'how should i define function that modifies list with only even numbers

i have created function with list input that modifies list and displays odd number divided by 2. This functions does what is should:

def modify_list(l):

    lst = [int(item) for item in input().split()]
    del l[:]

    for i in lst:
        if i % 2 == 0:            
            
            i = i // 2
            l.append(i)

print(modify_list(lst))  # None
print(lst)               # [1, 2, 3] 

here is my second function for same porpose but without input list:


def modify_list(l):

    lst = []

    
    for i in lst:
        if i % 2 == 0:
            i = i // 2
            lst.append(i)
            
lst = [10, 5, 8, 3]
modify_list(lst)
print(lst)               # [5, 4]

output is [10, 5, 8, 3], need to get 5 and 4

what am i doing wrong? i am really confused.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source