jeudi 21 novembre 2019

Is there a way i can read a list as individual variables in python

So to preface, i am very new to python (started about a week ago). I wanted to test my skills and create a program that allows the user to input a set of data into a list at which point it would be sorted and printed out into an array of positive varibles and negative ones.

numbers = list(map(float, input( 'Enter numbers: \n').split()))
positive_num=[]
negative_num=[]
for x in numbers:
    if numbers >0:
        positive_num.append(numbers)
    elif numbers <0:
         negative_num.appenend(numbers())

print('positive numbers: ' + positive_num)
print('negative numbers: ' + negative_num)
print("nuetral number: 0")

if im on the right path, its not working because numbers is a list and >0 is a variable so it cant compare the two. So all in all, the question im trying to get at is how do i make the list take each individual variable and test it against > or < to 0 so that i can put it into the array?

Maybe i did eveything all wrong at this point im pretty lost. Any help and explanations would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire