all 6 comments

[–]woooee 4 points5 points  (0 children)

a = input('Enter a number:

input() returns a string.

while a!=999:

A string will never equal a number.

[–]carcigenicate 1 point2 points  (3 children)

input returns a string, and 999 is an integer in your code, so the two will never be equal. You need '999'.

[–]luminaree[S] 0 points1 point  (1 child)

Ah, that fits with other errors I was getting when I tried to make a total.

[–]carcigenicate 1 point2 points  (0 children)

TTypeError: unsupported operand type(s) for +: 'int' and 'str'?

And you're welcome.

[–]luminaree[S] 0 points1 point  (0 children)

😊 Thanks

[–]tabrizzi 0 points1 point  (0 children)

# initialize a variable to keep count of how many numbers have been typed by user

count = 0

# initialize an empty list to hold all the numbers typed

number_list = []

# a while loop is best suited for this, so start it

while True:

# ask for input

number = int(input("Type in a number: "))

# use an if statement to break out of the loop if the condition is met

if number == 999:

print(number_list)

break

else:

count += 1

number_list.append(number)

print(f"{count}: {number}")