Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16743

Python for Everybody, Assignment 11.1 [closed]

$
0
0

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 16743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>