=+ for strings

Chris Angelico rosuav at gmail.com
Sun May 3 22:43:25 EDT 2020


On Mon, May 4, 2020 at 12:41 PM James Smith <bjlockie021 at gmail.com> wrote:
>
> I tried:
>     dt=+"{:02d}".format(day)
> but I got:
>     dt=+"{:02d}".format(day)
> TypeError: bad operand type for unary +: 'str'
>
> This works:
>     dt=dt+"{:02d}".format(day)
>
> Why can't I do the shortcut on strings?

The shortcut is += not =+ :)

ChrisA


More information about the Python-list mailing list