• + 2 comments

    Guys! I have a question related to Python, in this piece of code of yours - [x for x in numbers if x>0].

    What if I wanted to create a "new list" (which contains only negative numbers) from "numbers list" where numbers list is sorted in ascending order. I want to break the loop when x>= 0. So,

    a = [x for x in numbers if x >= 0: break]
    

    As you know this syntax is wrong, can you guys suggest me what is the proper way? I am new to Python.