3

When messing around in python with the exclamation mark, it said that it has to be followed by either !a, !s, or !r.
What does !a do?

Like can you do this?

f"{"txt"!a}"

What will be the result?

"TXT" # Obviously not this, but still
2
  • Why is this marked as a duplicate Commented May 6, 2024 at 14:54
  • The accepted answer on the duplicate answers your question, which you yourself confirmed in your self-answer. On Stack Overflow, duplicate has more to do with the answers than with the question itself. Commented May 7, 2024 at 10:16

1 Answer 1

2

Found the answer to my question in the accepted answer for this question:

!r (repr), !s (str) and !a (ascii) were kept around just to ease compatibility with the str.format alternative, you don't need to use them with f-strings.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.