I am having issues creating a menu-driven program that should accept integers and calculate the mean and median values and display them. I'm not having trouble calculating the Mean or Median, but I am having trouble with configuring the list into the program.
-
#Main
-
def main():
-
array = [] #this would be the list, but what do i do with it?
-
choice = displayMenu()
-
while choice != '4':
-
if choice == '1':
-
addNum()
-
if choice == '2':
-
calcMean()
-
if choice == '3':
-
displayMedian()
-
choice = displayMenu()
-
Now, this is my main function. I'm not completely sure what to do with the list. The next part would be the displayMenu() function, but that's correct so I'm not going to post it. However, next would be option number one, the addNum() function.
-
#adding numbers to the list
-
def addNum(): #how do I get it to return to the list in main?
-
number = raw_input("Enter number: ")
-
array.append(number)
-
I feel like I'm close to getting this correct, but at the same time I'm completely stuck and don't know what to do.
Any help, advice, and input would be greatly appreciated. thank you