I am creating a program that takes a list of user inputted integers and returns only the positive values in a list. My code is as follows:
def positive_numbers():
user_input = [int(input('Enter a positive number:'))]
numbers = []
for i in user_input:
if i >= 0:
numbers.append(i)
return numbers
When I call the function with print(f'{positive_numbers()}')
I get this error when inputting a list of values:
ValueError: invalid literal for int() with base 10: '1 2 4 56 -22 45'
I believe my issue resides woth the initial user input list, how would I fix this?