On 1/31/2019 11:19 AM, Ian Clark wrote:
text = "The best day of my life!"
output = ''

for i in text:
  if i == ' ':
   output +='\n'
  else:
   output += i

print(output)

throwing my hat in the ring, not only is it .replace free it is entirely
method free

But this is an awful, O(n*n) way to solve an inherently O(n) problem, which I think should not be taught to beginners unless they are simultaneously taught to never do this for indefinitely large n.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to