Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find-squares-and-odd-numbers-in-the-given-list

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
Comment

PREVIOUS NEXT
Code Example
Python :: disable network on pytest 
Python :: test register user mismatched passwords 
Python :: trace table python 
Python :: hypercorn initiate 
Python :: how to subset a dataframe in python based on multiple categorical values 
Python :: python last element of list using reverse() function 
Python :: How can I use Apache Spark with notebook in Anaconda 
Python :: mechanize python #11 
Python :: finda argument index 
Python :: django-filter field name greater than 
Python :: check string in a list for substrings and return index 
Python :: iterate rows 
Python :: python clean filename 
Python :: how to click the next button on a website using python 
Python :: python laplace expansion 
Python :: install requests-html modlule click on the link to learn more about requests-html 
Python :: cornell hotel sustainability benchmarking index 
Python :: splitting Feature and target using iloc 
Python :: parse filename 
Python :: pip install time python 
Python :: Using python permutations function on a list with extra function 
Python :: numpy random sin 
Python :: how to find the index of a specific number in pythong? 
Python :: vortex core line detection 
Python :: install python 3.10 pip 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: text xml 
Python :: Python NumPy asarray_chkfinite Function Example Tuple to an array 
Python :: Python NumPy append Function Example Working with axis 
Python :: Python __sub__ magic method 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =