print less than specific number in one row python
print([num for num in yourList if num < specificNum])
Here is what the above code is Doing:
1. We create a list of numbers from 1 to 10.
2. We create a variable called specificNum and set it to 5.
3. We create a new list called yourList.
4. We use a for loop to iterate through the list of numbers from 1 to 10.
5. We use an if statement to check if the number is less than specificNum.
6. If the number is less than specificNum, we add it to yourList.
7. We print yourList.