For a week now I have noticed this in my account on different notebooks. the situation with the syntax. Python stopped seeing f-lines. And the print function began to display everything in brackets for some reason.
Asked
Active
Viewed 573 times
0

Dmitry21 cheb
- 11
- 3
-
Irreproducible for me – U13-Forward Sep 11 '21 at 10:06
-
try this : `print(f"x={x}")` – I'mahdi Sep 11 '21 at 10:07
-
1you are using Python 2 – juanpa.arrivillaga Sep 11 '21 at 10:33
-
You are using a `python2` runtime in google colab. There should be a warning displayed when you run a cell. I suspect you opened an old notebook with a `python2` runtime. You can change it under `Runtime -> Change runtime Type`. – Michael Szczesny Sep 11 '21 at 10:34
2 Answers
0
You could actually narrow this code down to:
>>> print(f'{x=}')
x=5
>>>

U13-Forward
- 69,221
- 14
- 89
- 114
-
This works in the newest version, but the output (3.9.5) is a string – FLAK-ZOSO Sep 11 '21 at 10:36
0
The reason it doesn't work is because you are using Python 2. F-strings were added in Python 3.6, as you can see here or in this answer, so they don't work in any older version of Python.

Unnamed
- 3
- 4