0
To manipulate unsaved characters in variables with F'strings I do this:
print(f'{"String":^20}')
I wonder if this is right, or would it be a scam for the fact that I have to define the string inside the keys with double quotes, because if I use single quotes an error happens.
Why do you want to do this? This is looking like a XY problem. Without understanding the purpose of you wanting to do this, it is difficult to assess whether it would be gambiarra or not.
– Victor Stafusa
Using single quotes or double quotes is something else entirely. If the string starts with single quotes, then it ends with single quotes and then the double quotes will be a character like any other. If the string starts with double quotes, then it ends with double quotes and then single quotes will be a character like any other.
– Victor Stafusa
I totally understand. I started researching about F'strings, but I’ve never seen anyone use a string with quotes directly on the keys, so I ask. I could use the . format, and I’ve seen several exercises that use the . format with Python for manipulating strings outside variables, only never seen with F'strings.
– Delfino
You have to change the quotation marks because this is how it was defined: https://www.python.org/dev/peps/pep-0498/#escape-sequences
– hkotsubo
Got it, thanks @hkotsubo. I asked the question just because I hadn’t seen it anywhere else. If you want to answer the question, I will accept it, so we can close it, because I already have my answer. If you have no problem I can remove the question, but I would like to attribute the answer to you as it helped me.
– Delfino
Well, as Victor has already said, without more context, it’s hard to answer whether or not... It is a language resource and can be used (but like every resource, it can be misused as well, and it all depends on the context)
– hkotsubo