list1 = ["apple", "pear", "", "strawberry", "orange", "grapes", "", "watermelon"]
list2 = []
x = 0
while x < len(list1):
if len(list1[x]) > 0:
list2.append(list1[x])
print(list2)
I tried to run this code, but it seems that it doesn't work. How should I revise this code by not using list comprehension or other methods?