+ 2

F string not work in codeplayground but why?

x=('abc') print(f'my name is {x}') but it give error.but f string present in Python 3.why it execute error.

4th Apr 2018, 4:27 AM
Maninder $ingh
Maninder $ingh - avatar
2 odpowiedzi
+ 8
Andrey Vostokov Almost correct. You need the f before the string. https://cito.github.io/blog/f-strings/
7th Apr 2018, 9:56 AM
David Ashton
David Ashton - avatar
0
@Jan Markus, so basically the following two examples are executed identically? sl = 'SoloLearn' print('I love {}!'.format(sl)) & sl = 'SoloLearn' print('I love {sl}!')
4th Apr 2018, 7:55 AM
Andrey Vostokov
Andrey Vostokov - avatar