通过while循环得到列表

问题遇到的现象和发生背景

通过while循环,在【1,2,3,4,5,6,7,8,9,10】中得到仅有偶数的列表,但我出错了

用代码块功能插入代码,请勿粘贴截图
def while_func():
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
index = 0
list2= []
while indexelement = list[index]
    if element % 2 == 0:
        list2.append[element]
        index+=1
    print(f"通过while,源列表{list},取出偶数后的列表{list2}")
while_func()
def while_func():
    lis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    list2 = []
    index = 0
    while (index < len(lis)):
        element = lis[index]
        if element % 2 == 0:
            list2.append(element)
        index += 1
    print(f"通过while,源列表{lis},取出偶数后的列表{list2}")

while_func()

img


def while_func():
    list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    index = 0
    list2= []
    indexelement = 0
    while indexelement < list.__len__() :
        if list[indexelement] % 2 == 0:
            list2.append(list[indexelement])
            index+=1
        indexelement+=1
    print(f"通过while,源列表{list},取出偶数后的列表{list2}")
while_func()


def while_func():
    list = [1,2,3,4,5,6,7,8,9,10]
    index = 0
    list2 = []
    while index < len(list):
        if list[index] % 2 == 0:
            list2.append(list[index])
        index += 1;
    print(str(list) + " " + str(list2))
while_func();