remove empty string from the list of strings

Sai_kiran_rachakonda · November 01, 2022
list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"]
result = [x for x in list1 if x != ""]
print(result)

                       #or
                       
for i in list1:
    if i != "":
        print(i)
    else:
        pass
Output

Comments

Please sign up or log in to contribute to the discussion.