📜  在给定列表中查找平方和奇数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:25.335000             🧑  作者: Mango

代码示例1
def squareodd(num):
    #lst = () # 'tuple' object has no attribute 'append'
    lst = []
    for i in num:
        # if num % 2 == 1: # you are trying to use the % (modulo) operator on the list instead on item of list 
        if i % 2 == 1:
            lst.append(i**2)
    return lst