Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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!

  • Custom User Avatar

    I'm confused as to why it knows c represents characters in the strings

  • Custom User Avatar

    Hi, new to coding. Why is else being used for no reason in this example?