I'm trying to insert a newline every 40 characters. I'm very new to Python so I apologize if my code is messed up.
def wrap(msg):
pos = 0
end = msg
for i in end:
pos += 1
if pos % 40 == 0:
print(pos)
end = end[:pos] + "\n" + end[:pos + 2]
return end
This code doesn't work and there isn't any errors. I'm not sure why this happens. It seems to just return the full string??