Skip to content

Instantly share code, notes, and snippets.

View j4jeyaram's full-sized avatar

JEY j4jeyaram

View GitHub Profile
@j4jeyaram
j4jeyaram / Write a program which repeatedly reads numbers until the user enters “done”. Once “done” is entered, print out the total, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except an
Last active May 17, 2020 14:24
Write a program which repeatedly reads numbers until the user enters “done”. Once “done” is entered, print out the total, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number.
count=0
total = 0
inp = 1
while True:
try:
number = input('Enter a number')
if number == 'done':
break
inp = int(number)
count = count + 1