I am in the process of learning Python and I have reached the section about the pass
statement. The guide I\'m using defines it as being a Null
sta
Here's an example where I was extracting particular data from a list where I had multiple data types (that's what I'd call it in R-- sorry if it's the wrong nomenclature) and I wanted to extract only integers/numeric and NOT character data.
The data looked like:
>>> a = ['1', 'env', '2', 'gag', '1.234', 'nef']
>>> data = []
>>> type(a)
>>> type(a[1])
>>> type(a[0])
I wanted to remove all alphabetical characters, so I had the machine do it by subsetting the data, and "passing" over the alphabetical data:
a = ['1', 'env', '2', 'gag', '1.234', 'nef']
data = []
for i in range(0, len(a)):
if a[i].isalpha():
pass
else:
data.append(a[i])
print(data)
['1', '2', '1.234']