i want to leave ''
vacant number from list and print data
numbers= ['123','456','','789']
I want result like this:
123
456
789
Check if the string in numbers is empty or not with if
for num in numbers:
if num:
print(num)
''
- the empty string is False
-ey so it won't be printed
Using a for
loop and an if
statement to catch empty strings, you could do the following:
for number in numbers:
if not number:
continue
else:
print(number)
# prints this
123
456
789