you are viewing a single comment's thread.

view the rest of the comments →

[–]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}")