Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
and also the one of 431 other players :-)
My solution
Because for char in s, we are iterating over each character in the string s, and for each character c, we are multiplying it by 2 (c * 2) to create a new string with the character repeated twice. The join() method is then used to concatenate all the doubled characters into a single string.
see the comments below. this solution was written in Pyrthon 2. Python 3 changed the
round()
function for halfway cases: it used to be half away from zero (0.5 --> 1
,1.5 --> 2
), now it's half towards the nearest even integer (the so-called "banker's rounding"): (0.5 --> 0
,1.5 --> 2
)How come when I did it it was incorrect????
Which verion did you do?
Really good to know that this exist.
not efficient
Nice!
This comment is hidden because it contains spoiler information about the solution
Less lines of code = better
duh
This is really quite novel. Nice!
It's not dissimilar to a 'for' loop with a list. Think of it as 'for [any item] in [what I'm telling you to look at]'.
In this case we're telling the program to look at a string, so the 'any item' is just 'any/each individual letter'. 'C' is simply a placeholder for that.
I appreciate this is checks watch 11 months late, but I hope it helps if you ever return here!
how did such a suboptimal solution get to the top?
This comment is hidden because it contains spoiler information about the solution
That's brilliant! I would have never thought of that myself!
Loading more items...