黑馬程序員python教程,8天python從入門到精通,學python看這套就

有沒有大佬指正一下 這段代碼哪里出錯了呀 def list_while_func():
list = ['1', '2', '3', '4', '5', '6', '7','8','9']
list2 = []
index = 0
while index < len(list):
a = list[index]
if a % 2 == 0:
list2.append(a)
index += 1
print(f"通過while循環(huán),從列表:{list}中取出偶數(shù),組成新的列表{list2}")
list_while_func()
標簽: