##This project will ask customers for the flavor ice-cream they would ##like to order. If the flavor is not available the program will end. ## Each flavor the customer enters will write in a file called IceCreamOrder.txt. ##The inventory will be conducted at the very end. ##Loops, Files and Strings f=open("IceCreamOrder.txt" , 'w') while True: data=input("Please enter the flavor of ice-cream you would like.If the flavor you want is not on the list please hit enter:") f.write(data) f.write("\n") if data == "": break f.close() ##List and Dictionary #textfile=input("Enter the inventory file name:") print("Today's ice-cream sales is:") f=open("IceCreamOrder.txt",'r') L=[] for line in f: wordList=line.split() for word in wordList: L.append(word) Dictionary={} for element in L: number=Dictionary.get(element,None) if number==None: Dictionary[element]=1 else: Dictionary[element]=number+1 keys=list(Dictionary.keys()) keys.sort() for key in keys: print(key+" "+str(Dictionary[key])) ##Function f=open("IceCreamOrder.txt",'r') L=[] wordList=[] for line in f: wordList=line.split() for word in wordList: L.append(word) def func(): wordlist==word print(word) def main(): print("List before calling func", wordList) func() print("List after calling func", wordList)