+ 1
How did he come up with this answer
>>> 4 * '2' '2222'
3 Answers
+ 5
When an object is enclosed in double or single quotes then it is considered as a string. Here 2 is considered as a string and when a string multiplied with 4 it is repeated 4 times and thus output is '2222'
+ 3
'2' is a string, like 'a' or 'spam'
once you multiply it for a number, you are actually repeating it n times
so, 'spam'*4 prints out 'spamspamspam'
give a try
+ 2
thanks to you all very much