How to deal with an Item in a List in Python?

This recipe helps you deal with an Item in a List in Python

Recipe Objective

Have you tried to change any item in a array or tired to manupulate it?

So this is the recipe on how we can deal with an Item in a List in Python.

Step 1 - Creating List

We have created a list named sales with different values Sales = [482, 93, 392, 920, 813, 199, 374, 237, 244]

Step 2 - Changing Values

Here we have defined a function to return the values after adding 100 to the previous value. After that we have mapped this updated feature and sales. def updated(x): return x + 100 print(list(map(updated, Sales))) Now we have defined a loop in which we will add 10 to each value of previous feature i.e updated. salesUpdated = [] for x in Sales: salesUpdated.append(x + 10) print(salesUpdated) Now we have defined a mapping function to add 100 in each value of items in sales and we are using lambda function for this. print(list(map((lambda x: x + 100), Sales))) So the output comes as

[582, 193, 492, 1020, 913, 299, 474, 337, 344]

[492, 103, 402, 930, 823, 209, 384, 247, 254]

[582, 193, 492, 1020, 913, 299, 474, 337, 344]

Download Materials

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

Build a Autoregressive and Moving Average Time Series Model
In this time series project, you will learn to build Autoregressive and Moving Average Time Series Models to forecast future readings, optimize performance, and harness the power of predictive analytics for sensor data.

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Hands-On Approach to Master PyTorch Tensors with Examples
In this deep learning project, you will learn how to perform various operations on the building block of PyTorch : Tensors.

Model Deployment on GCP using Streamlit for Resume Parsing
Perform model deployment on GCP for resume parsing model using Streamlit App.

Tensorflow Transfer Learning Model for Image Classification
Image Classification Project - Build an Image Classification Model on a Dataset of T-Shirt Images for Binary Classification

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

MLOps Project on GCP using Kubeflow for Model Deployment
MLOps using Kubeflow on GCP - Build and deploy a deep learning model on Google Cloud Platform using Kubeflow pipelines in Python