0
How to create a list consisting of the negative values in the last numbers. Associate the new list with the variable negtives.
3 Answers
0
can't fully understand what you mean
if you have some list with numbers and you want to create another list with negatives of that numbers, you can do something like this:
list1 = [1, 2, 3] #your first list
list2 = list() #creating new empty list
for n in list1: #going through first list
list2.append(-n) #adding negative item
0
I meant list numbers not last. thanks for your input. I have a negative list and can't figure out how to make the new list with negative numbers
0
list1=[-1,_2,_3,0,1,2,3]
list2=[]
for num in list1:
if num<0:
list2.append(num)
print(list2)