Nov-01-2022, 05:13 PM
Here a hint,there is no need to complitcate the loop just loop over the string.
line = 'The high today will be 15 degrees' temp = '' for c in line: if c.isdigit(): temp += c print(int(temp))
Output:15