In: Computer Science
Write a program that prompts the user to enter a series of strings, but with each string containing a small integer. Use a while loop and stop the loop when the user enters a zero. When the loop has finished, the program should display:
Any help is greatly appreciated, this is for python 3
I am not given any more information. this is all the professor has told me
import re
total_inputs = 0
sum_of_numbers = 0
# Ask user to enter string
input_string = input('Enter a string: ')
# Check if string is not 0
while input_string != '0':
# Increment total_inputs by 1
# Find integer in string and store in num
# Add num to sum
total_inputs += 1
num = re.findall('\d+', input_string)[0]
sum_of_numbers += int(num)
# Ask user to enter string again
input_string = input('Enter a string: ')
# Calculate average
average = sum_of_numbers / total_inputs
# Display result
print('\nNumber of user Inputs:', total_inputs)
print('Total of the integers:', sum_of_numbers)
print('Average of the integers: %.1f' % average)
SCREENSHOT-

OUTPUT
