# Method: Append a new price level to the levelsList
def addLevel(self):
try:
# Let the user enter a new float value and append it to the list
...
except:
# Print and error message if the user entered invalid input
...
# Method: Remove an existing price level from the levelsList
def removeLevel(self):
try:
# Let the user enter a new float value. If found in the list, remove it from the list
...
except:
# Print and error message if the user entered invalid input
...
# Method: Set levelsList to an empty list
def removeAllLevels(self):
# Set levelsList to an empty list
...
Replace ellipsis "..." with code
# Method: Append a new price level to the levelsList
def addLevel(self):
errorMsg2 = "The number entered is invalid, please enter a number greater than 0."
try:
# Let the user enter a new float value and append it to the list
userPrice = float(input("Enter the price level to add: "))
self.__levelsList.append(userPrice)
except:
# Print and error message if the user entered invalid input
if userPrice < 0:
print(errorMsg2)
# Method: Remove an existing price level from the levelsList
def removeLevel(self):
errorMsg2 = "The number entered is invalid, please enter a number greater than 0."
try:
# Let the user enter a new float value and append it to the list
userPrice = float(input("Enter the price level to add: "))
if userPrice in self.__levelsList:
self.__levelsList.remove(userPrice)
except:
# Print and error message if the user entered invalid input
if userPrice < 0:
print(errorMsg2)
# Method: Set levelsList to an empty list
def removeAllLevels(self):
self.__levelsList.clear()
Comments
Leave a comment