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 đ˘
3 Answers
+ 2
A variable is a place holder it allocates space to store somthing
these are place holders in string formatting
%d
%s
+ 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}!')
+ 1
Thanks guys