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

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

Build Classification Algorithms for Digital Transformation[Banking]
Implement a machine learning approach using various classification techniques in Python to examine the digitalisation process of bank customers.

Build a Multi-Class Classification Model in Python on Saturn Cloud
In this machine learning classification project, you will build a multi-class classification model in Python on Saturn Cloud to predict the license status of a business.

Build a Text Generator Model using Amazon SageMaker
In this Deep Learning Project, you will train a Text Generator Model on Amazon Reviews Dataset using LSTM Algorithm in PyTorch and deploy it on Amazon SageMaker.

Build a Credit Default Risk Prediction Model with LightGBM
In this Machine Learning Project, you will build a classification model for default prediction with LightGBM.

Deploying Machine Learning Models with Flask for Beginners
In this MLOps on GCP project you will learn to deploy a sales forecasting ML Model using Flask.

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

LLM Project to Build and Fine Tune a Large Language Model
In this LLM project for beginners, you will learn to build a knowledge-grounded chatbot using LLM's and learn how to fine tune it.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.