What are place holder variables and how do they work? Is it the same as formatting expressions? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What are place holder variables and how do they work? Is it the same as formatting expressions?

I need adequate info on this with examples cuz I'm tired of getting errors as output when running codes 😢

29th Aug 2019, 6:39 PM
Onimisi
Onimisi - avatar
3 Answers
+ 2
A variable is a place holder it allocates space to store somthing these are place holders in string formatting %d %s
30th Aug 2019, 11:20 AM
D_Stark
D_Stark - avatar
+ 1
I recommend to read through this. Really, because it is a complicated topic. https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-string-formatting/ There are many ways to do variable substitution and formatting in strings. My favorite method is the f-string (introduced in python 3.6) in which case you don't even need placeholders, you just embed the variable inside the text like so: w = 'World' print(f'Hello {w}!')
29th Aug 2019, 7:02 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Thanks guys
30th Aug 2019, 8:29 PM
Onimisi
Onimisi - avatar