Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

map in python

price_list=[120,250,133,420,145,369,700]
# given alist of prices
def sale(price):
  # function for add discount in sale for evry price
      discount=(15/100)
    # discount 15%
      new_price = price*discount
      # new price
      return new_price
      
new_price_list=list(map(sale,price_list))

# 120*15% , 250*15)3*15%
# use map function take evry price in price list
# add evry  price to slae funtion
# add discount to this price return new price 
# add evry new price in new_price_list
print(f"price list in sale {new_price_list}")
#print new list of prices
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #map #python
ADD COMMENT
Topic
Name
5+4 =