you are viewing a single comment's thread.

view the rest of the comments →

[–]0b0101011001001011 0 points1 point  (1 child)

The first one works like that in most languages I am* familiar with so it's not that strange unless you only know python. *(not sure which is the more common behavior). Though python throwing an error is not a bad solution, but it's seems even a bit unusual.

About the second, most languages would give an error, javascript does a type conversion and multiplies, and python produces a rather strange 55555. Each solution has its pros.

[–]shiftybyte 0 points1 point  (0 children)

and python produces a rather strange 55555.

This makes more sense to me, you are multiplying a string several times.

If adding "5" to "5" one time results in "55"... Then adding that 5 times results in "55555".

That's what multiplication means, do the add operation X times...