Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

question about HW1

d
digamma (480 points)
2 4 5
in HW1 optional by (480 points)
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?
375 views
closed

4 Answers

Best answer
gianluca5539 (9820 points)
4 6 44
by (9.8k points)
selected by

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
by (7.8k 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)
15 20 65
by (6.1k points)
edited by
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
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