10/15: How to use the hint given?


I did solve it using my own way, as follows:

def censor(text,word):
  for i in text:
  print newLst
  for i in range(len(text)):
    if text[i:i+len(word)]==word:
      for n in range(len(word)):
  return "".join(newLst)

but when I checked the hint to see what codecademy’s method was, I couldn’t figure out all the steps…
(was .split() fuction taught in the course?)

Can we distinguish between 2 functions that give the correct results to the same problem in diff ways, to figure which is better?(maybe something like time taken etc.?)

P.S: How does codecademy make those cool default display pictures that are different for every user?:yum:


if a function hasn’t been taught, you can always check documentation.

once we separated the sentence into a list containing each word, we can simple replace the words which require censoring. Which requires range(), given we need indexes to update list elements

time taken, memory used, readability of the code and so forth. There are so many factors, and which code is “best” can depends on circumstances. If performance is required, spending more time optimizing is justified where in other cases the time spend optimizing isn’t justified.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.