0
list1 = []

while True:
    num=input("enter a number or input q to quit or input a for the average\n")
    if isinstance(num, int):
        list1.append(num)
    elif isinstance(num, str):
        if num == "q":
            exit()
        elif num == "a":
            print(list1)
        else:
            print("stop")

I'm a python beginner, and I've made this program to find the average of integers in a list, but for some reason it does not add any integers to the list. I don't know why it doesn't work

kimm2
  • 9
  • 2
    What does the `input` function return in Python 3.x? – ForceBru Jun 25 '18 at 04:45
  • you're just appending numbers in list and print list while user press 'a'. – Vishal Khichadiya Jun 25 '18 at 04:45
  • `num` is a string, not an integer. Because `isinstance` is returning false, nothing is being added. – Rohan Jun 25 '18 at 04:47
  • Debuggers like [PythonTutor](http://pythontutor.com/visualize.html#mode=edit) can help you find the reason for seemingly strange script behavior. ForceBru and Rohan have already explained, why your list does not contain anything. – Mr. T Jun 25 '18 at 04:52

0 Answers0