# question about HW1

d
digamma (480 points)
2 4 5
asked Oct 26, 2021
Guys i have a question aout homework.1.

since the int_seq should be a string , containing several sequence of integers separated by commas, the integers themselves should only have 1 digit yes?

so for example the int_seq = '12,0,153,16' is not valid?
150 views

gianluca5539 (9820 points)
3 6 44
answered Oct 26, 2021 by (9,820 points)
selected Oct 27, 2021 by digamma

There is no limit to the number of digits. I think you wanted all numbers to be only one digit to create a list with the numbers, using a step = 2 so that you exclude the commas.

There is a way to make a list of all the numbers from a string, if these numbers are separated by a character. The method is split(character) and in this case character is the comma, so

list = string.split(",")

This will return a list of STRINGS (not int!) each containing one of the numbers.

Hope this helps.

GabrielAlexandru (7760 points)
2 4 29
answered Oct 26, 2021 by (7,760 points)
Itâ€™s definitely a valid string. The integers can be made of n digits, up to the maximum value storable in memory.

If I remember correctly in the example there are some number with more than one digit.
Luigi Pizza (6120 points)
11 20 65
answered Oct 26, 2021 by (6,120 points)
edited Oct 26, 2021
Yes, that is a valid string, as the professors and the test did not tell us about any restriction of the number of digits a sequence can have.

I suggest either to use a list comprehension (but we haven't studied it yet), to write a list of ints, or you can even use the map function we have studied today with prof Mancini (obviously after applying the method .split(',')) if you don't want to use a for.
Excale (490 points)
0 0 6
answered Oct 26, 2021 by (490 points)

There shouldn't be a maximum for the numbers, you can see it yourself from the test strings.

It seems though (somebody correct me if I'm wrong, I haven't checked the entire file) that in the tests there are no more than 3 digits per number. See the screenshot down here.

So the sequence '12,0,153,16' is indeed valid