Can someone explain what is usage of f-string . I mean print(f" ghh {} ") . What can be in brackets? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Can someone explain what is usage of f-string . I mean print(f" ghh {} ") . What can be in brackets?

Python

19th Aug 2022, 9:34 AM
Amzara
2 Respuestas
+ 11
Also called “formatted string literals,” f-strings are string literals that have an f at the beginning and curly braces containing expressions that will be replaced with their values. The expressions are evaluated at runtime and then formatted using the __format__ protocol. Eg: x = 7 print (f"T he value of x is {x}")
19th Aug 2022, 9:45 AM
Sreeju
Sreeju - avatar