Hi community!
i just started learning python and have been using jupyter notebook. Was trying to run a mean code to calculate it based on numbers pasted with " " in between. I used AI to help me with this code and it worked on google collab, but when I try on Jupyter I get this message:
def calculate_mean_from_space_input(space_input):
# Split the input string by spaces to get individual numbers as strings
number_strings = space_input.split(' ')
# Convert each string to a float and collect them in a list
numbers = [float(num) for num in number_strings]
# Calculate the mean
mean = sum(numbers) / len(numbers) if numbers else 0
return mean
# Prompt the user for input
space_input = input("Enter numbers separated by spaces: ")
# Calculate and print the mean
mean = calculate_mean_from_space_input(space_input)
print(f"Mean: {mean}")
Cell not executed due to pending input
The cell has not been executed to avoid kernel deadlock as there is another pending input! Submit your pending input and try again.
Thank you!