Python Forum
The "traceback" is here
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The "traceback" is here
#1
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?
Reply


Messages In This Thread
The "traceback" is here - by AmanTripathi - Feb-14-2018, 04:17 PM
RE: The "traceback" is here - by metulburr - Feb-14-2018, 06:22 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020