Saadi381 Saadi381 - 1 year ago 61
Python Question

Converting String into Integer and matching to an integer

been trying this with no luck

y = ("586MB Available")
x= re.findall (r'\d+',(y))

>>> x

if x == 586:
print ('yes')
else :
print ("No")


tst tst
Answer Source

x is a list of string. You must convert the first element to an int:

int(x[0]) == 586

or if you want to have an inequality:

int(x[0]) < y