Read txt, convert each number to int, comma separated in Python
Hello everybody! I need to read a txt file with a variable number of lines, each line has the following structure:
1,6,11,15,47
1,2,11,25,34
1,38,40,46,50
5 random numbers per line ranging from 1 to 50, I can read it and save it to the list but I can't get it to be like int.
I'm reading it like this:
import random
from os import system
system('clear')
fileTxt = open('filetxt.txt', "r")
mainList = []
def createList():
card = []
for lineTxt in fileTxt:
mainList.append(lineTxt.rsplit())
Can you help me? Thanks!