Join the IDNLearn.com community and start finding the answers you need today. Join our interactive community and access reliable, detailed answers from experienced professionals across a variety of topics.
Answer:
nums = []
while True:
in = input()
if in:
nums.append(in)
else:
break
if nums:
avg = sum(nums) / len(nums)
for i in range(len(nums)):
if nums[i] == avg:
print(f"index: {i+1}")
print(nums[i])
else:
print(-1) # if there aren't any values in nums
Explanation:
Assuming that you are coding in Python 3x. The last 'else' statement is an edge case that you might want to consider, I don't know what you want to put there, but I'm just going to leave it as -1.