# Create displayList
displayList = []
# Loop through the prices in levelsList.
# During each loop:
# - Create a variable called priceLevelLabel consisting of the text 'Price Level: '
followed by the price.
# - Add priceLevelLabel and the price as two separate items to a new list (the sub-List).
# - Append the sub-List to displayList. for price in self.levelsList:
. . .
# Create a variable called previousPriceLabel consisting of the text 'Previous Price: ' followed
# by previousPrice. # Add previousPriceLabel and previousPrice as two separate items to a new list (the sub-List). # Append the sub-List to displayList.
. . .
# replace ellipsis with applicable cod
import re
displaylist = [100, 300, 500, 700, 900]
# Using for loop to loop through the prices
for i in displaylist:
print(i)
priceLevelLabe="price level"
priceLevelLabel=300
def sub_list(lst):
lst.append(lst[-2:])
return lst
#Append the sub-List to displayList. for price in self.levelsList
print(sub_list(["price level",300]))
previousPriceLabel="Previous Price"
previousPriceLabel=500
def sub_list(lst):
lst.append(lst[-2:])
return lst
#append the sub_list to display list
print(sub_list(["Previous level",500]))
# replacing elipsis with applicable code
display_list = ["price1", "price2", "price3...", "price.4"]
for i in range(len(display_list)):
display_list[i] = re.sub("\.", "", display_list[i])
display_list[i] = re.sub("\.{3}", "", display_list[i])
display_list[i] = re.sub("\.\.\.", "", display_list[i])
for text in display_list:
print(text)
Comments
Leave a comment