I have this function, but I am getting this error. I have tried but am not able to fix this.
size -= len(prefix)
if size % 2:
size -= 1
return '\n'.join([prefix + line for line in textwrap.wrap({size, string})])
I have this function, but I am getting this error. I have tried but am not able to fix this.
size -= len(prefix)
if size % 2:
size -= 1
return '\n'.join([prefix + line for line in textwrap.wrap({size, string})])
Copyright © 2021 Jogjafile Inc.
It seems like you're trying to do something like this:
which returns:
However, you are passing
{size, string}as a parameter to the textwrap.wrap method while the wrap method expects the first parameter to be a string:To illustrate this we can check the type of the object you are passing (which is a set object):
returns
<class 'set'>.As it happens, this can all be simplified if you use
textwrap.fillinstead ofwrap: