find squares and odd numbers in the given list

Solutions on MaxInterview for find squares and odd numbers in the given list by the best coders in the world

showing results for - "find squares and odd numbers in the given list"
Kitty
19 Jan 2017
1def squareodd(num):
2    #lst = () # 'tuple' object has no attribute 'append'
3    lst = []
4    for i in num:
5        # if num % 2 == 1: # you are trying to use the % (modulo) operator on the list instead on item of list 
6        if i % 2 == 1:
7            lst.append(i**2)
8    return lst
9
similar questions