Quantcast
Viewing all articles
Browse latest Browse all 14040

Python for Everybody, Assignment 11.1 [closed]

Coursera Python for everybody assignment 11.1/Python Regex.

import rename = input("Enter file: ") hand = open(name, 'r')sums = []for line in hand:     line = line.rstrip()     line = re.findall('[0-9.]+',line)     line = int(line)     if line:         sums.append(int(match.group(1)))print(sum(sums))

Python for Everybody assignment 11.1 The actual goal is to read a file, look for integers using the re.findall() looking for a regular expression of [0-9]+, then converting the extracted strings to integers and finally summing up the integers.

Pycharm is returning:TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'


Viewing all articles
Browse latest Browse all 14040

Trending Articles