- 1
Can variables be manipulated within a print statement? (Python) Like: x = 3 print(x *=3)
Variables and 'print'
4 Respuestas
+ 1
Pls add Language name in tag where you have added operator,also your question isn't clear if you could provide more details or code on what you mean that will be helpful
+ 1
Assignation statements have no return value in Python (conversely to others languages such as JS)...
So theoricaly, you could expect "None" outputed by printing such things... but it fail with errors, either explicit (raised) or implicit (logical):
>>> print(a=42)
TypeError: 'a' is an invalid keyword argument for this function
>>> print(end=42)
TypeError: end must be None or a string, not int
>>> print(end="forty-two")
forty-two>>> print(end)
NameError: name 'end' is not defined
>>> end = 42
>>> print(end="forty-two")
forty-two>>> print(end)
42
>>> x = 3
>>> print(x*=3)
SyntaxError: invalid syntax
0
No but they can be mapped