Commas In matrices

Luigi Pizza (6120 points)
11 20 65
asked Nov 26, 2021 in HW6 by Luigi Pizza (6,120 points)
edited Dec 2, 2021 by Luigi Pizza

Every line inside each of the text files of the folder matrices never never ends with a number but always with one and just one comma.

For anybody interested there is a part of the comment in that states:

''''The file contains on each line groups
of 5 integer values, followed by 1 comma and/or 0 (or more) spaces or

So there will always be a final comma.


2 Answers

enricomaria.follega (710 points)
4 8 13
answered Nov 26, 2021 by enricomaria.follega (710 points)

cool just use .split() method to hundle spaces and commas and .isnumeric() method to hundle integers. cool

There cannot be negative and float numbers thus all .isnumeric() exeptions will stay out of the program in any case.

Once you implemented these methods any letter or symbol the string is spaced with or ended with, shouldn't bother you at all.

Excale (490 points)
0 0 6
answered Nov 29, 2021 by Excale (490 points)

It shouldn't be a problem.

What you expect on every line are n numbers which tell you info about the buildings. Every building requires 5 numbers (width, height and 3 for colour), so write your code on the assumption that n is gonna be a multiple of 5 (always true) and you're good to go.