I have to extract all the numbers in the file and compute the sum of the numbers.
import re sum=0 name=input('Enter name of file:') file=open(name) for lines in file: numbers=re.findall('[0-9]+') if len(numbers) == 0: continue for num in numbers: no=int(num) sum=sum+no print(sum)The traceback :
Error:Traceback (most recent call last):
File "F:/Python Programs/regular_ass.py", line 7, in <module>
numbers=re.findall('[0-9]+')
TypeError: findall() missing 1 required positional argument: 'string'
Can someone please explain me the traceback and why is it here?