[Python] SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am very new to Python and I was currently playing around with str() function and tried to convert a floating number into a string. I tried using the below code to convert 0.005 into string, I got the error. However, when I use x=str(x), it worked. Could anyone please advise the logic behind the error?

    >>> x
    0.005
    >>> x=str(x)
    >>> x
    '0.005'
    >>> str(x) = 0.005
    SyntaxError: cannot assign to function call here. Perhaps you meant '==' instead of '='?


    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página