Okay I'm having a little trouble making this program that adds numbers to a blank list and then having the user choose when to quit the program, and when the user chooses to quit the program will automatically find the average and display it. But whenever the user quits the program it adds 'q' to the list and then obviously crashes it because it can't find the average with a letter in it.
def listsave():
list1 = []
x = None
while True:
x = input('Enter integer (q to quit):')
if x != 'q':
list1.append(x)
else:
return sum(list1)/len(list1)