Answer to Question #178325 in Python for tas

Question #178325

Write a program to get numbers as input from the user and save them in a list. The program should keep getting the input until they type, Quit. If they typed Quit, it should stop asking for the input and should print the number they have typed. 


1
Expert's answer
2021-04-05T04:22:22-0400
#!/usr/bin/env pyhton
numbers = []

while True:
    s = input('Enter a number or "Quit" to exit: ')
    if s == 'Quit':
        break
    x = int(s)
    numbers.append(x)

print('The number you have enterd:')
for x in numbers:
    print(x, end=' ')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS