Related Articles
Python program to print all negative numbers in a range
• Last Updated : 26 Oct, 2018

Given start and end of a range, write a Python program to print all negative numbers in given range.

Example:

```Input: start = -4, end = 5
Output: -4, -3, -2, -1

Input: start = -3, end = 4
Output: -3, -2, -1```

Example #1: Print all negative numbers from given list using for loop

Define start and end limit of range. Iterate from start till the range in the list using for loop and check if num is less than 0. If the condition satisfies, then only print the number.

 `# Python program to print negative Numbers in given range`` ` `start, end ``=` `-``4``, ``19`` ` `# iterating each number in list``for` `num ``in` `range``(start, end ``+` `1``):``     ` `    ``# checking condition``    ``if` `num < ``0``:``        ``print``(num, end ``=` `" "``)`

Output:

`-4, -3, -2, -1 `

Example #2: Taking range limit from user input

 `# Python program to print negative Numbers in given range`` ` `start ``=` `int``(``input``(``"Enter the start of range: "``))``end ``=` `int``(``input``(``"Enter the end of range: "``))`` ` `# iterating each number in list``for` `num ``in` `range``(start, end ``+` `1``):``     ` `    ``# checking condition``    ``if` `num < ``0``:``        ``print``(num, end ``=` `" "``)`

Output:

```Enter the start of range: -15
Enter the end of range: 5
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 ```

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up