Answer to Question #240643 in Python for Licinda Wait

Question #240643


# 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


1
Expert's answer
2021-09-22T23:43:44-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS