F string not work in codeplayground but why? | Sololearn: Learn to code for FREE!

+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.

4/4/2018 4:27:22 AM

Maninder $ingh

4 Answers

New Answer

+6

This is introduced in Python 3.6 and codeplayground does use Python 3.5 at the moment. https://code.sololearn.com/c5ip6FphjodA/?ref=app

+8

Andrey Vostokov Almost correct. You need the f before the string. https://cito.github.io/blog/f-strings/

+5

Andrey Vostokov No. Your second example does not work. If you want to insert something into the curly braces, then you have to use the format-keyword.

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}!')