Saadi381 Saadi381 - 5 months ago 13
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
['586']

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


No

tst tst
Answer

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
Comments