i am running a program that takes a list of numbers and letters, and separates the numbers into a sperate list and printing that list, but every time i run the code it says that isalpha is not defined.
yes = []
item=[1,7,-10,34,2,"a",-8]
for things in item:
if isalpha() ==True:
continue
else:
yes.append
print(yes)
.isalphais a method not a function (see this tutorial to learn more about the difference), so it cannot be called by name. I think you wantor
Also, the
elseis not necessary aftercontinue, so you can follow withyes.append(things)(not justyes.append):(But why are you printing
yes[potentially on repeat] inside the loop instead of after the loop?)Alternately you could just use list comprehension (view output)