Answers for "Square Odd Python"

0

Square Odd Python

### START FUNCTION
def square_odd(pylist):

    numbers = []
    for i in range(len(pylist)):
        item = int(pylist[i])
        if item % 2 == 1:
            numbers.append(item**2)

#     Using a list comprehension
#     numbers = [int(x)**2 for x in pylist if int(x)%2==1]

    return numbers
### END FUNCTION
Posted by: Guest on April-09-2022

Python Answers by Framework

Browse Popular Code Answers by Language