youtube cannot accept angled brackets in description kindly check the video for the missing angled brackets in the below code
Output
Negative numbers in the list: -10 -21 -4 -66
Python program to print negative Numbers in a List
list of numbers
list1 = [11, -21, 0, 45, 66, -93]
iterating each number in list
for num in list1:
checking condition
if num 0:
print(num, end=" ")
Output:
-21 -93
Python program to print negative Numbers in a List
list of numbers
list1 = [-10, 21, -4, -45, -66, 93]
num = 0
using while loop
while(num len(list1)):
checking condition
if list1[num] 0:
print(list1[num], end=" ")
increment num
num += 1
Output:
-10 -4 -45 -66
Python program to print negative Numbers in a List
list of numbers
list1 = [-10, -21, -4, 45, -66, 93]
using list comprehension
neg_nos = [num for num in list1 if num 0]
print("Negative numbers in the list: ", *neg_nos)
Output
Negative numbers in the list: -10 -21 -4 -66
Python program to print negative Numbers in a List
list of numbers
list1 = [-10, 21, 4, -45, -66, 93, -11]
we can also print negative no's using lambda exp.
neg_nos = list(filter(lambda x: (x 0), list1))
print("Negative numbers in the list: ", *neg_nos)
Output
Negative numbers in the list: -10 -45 -66 -1
l=[12, -7, 5, 64, -14]
print([a for j,a in enumerate(l) if a0])
Output
[-7, -14]
Python program to print negative numbers in a list
Python program to print positive numbers in a list
Python program to print all odd numbers in a range
Python program to print all even numbers in a range
Python program to print odd numbers in a List
Python program to print even numbers in a list
Python program to find second largest number in a list
Python program to find largest number in a list
Python program to clear a list || code in description
Python program to find sum of elements in list
python code to Check if element exists in list or not
Python Program for Sum of squares of first n natural numbers
Python Program for factorial of a number
Python code To find compound interest #shorts #python
Python program to find the maximum of two numbers #shorts #python
Python Program to Convert Kilometers to Miles
Python Program to Generate a Random Number #shorts #python
Информация по комментариям в разработке