There is a cycle that returns data, you need to take only the second value (8 digits). Tell me where to run, at least ...

  • [5453]
  • [12345678]
  • []
  • [124]

My code is:

for r in result: res = r.get_text() res = [int(''.join(i)) for is_digit, i in groupby(res,str.isdigit) if is_digit] print (res) 
  • one
    Nothing is clear. Why are the values ​​in brackets like list? Specify what it means - "returns values". - MBo

1 answer 1

 val = """5453 12345678 124""" [ int(i) for i in val.split('\n') if i and int(i)>9999999] [12345678] 
  • instead of i!='' just i -> if i and int(i) > 9999999 - gil9red
  • @ gil9red thanks, I agree. - S. Nick
  • one
    It is better to use val.splitlines () instead of val.split ('\ n') - MaxU