Python Forum
what's really wrong with this f-string?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what's really wrong with this f-string?
#1
what's really wrong with this f-string? the quotes look right so it must be the backslash.
Output:
>>> a=432 >>> s=f'{a} "\{"' File "<stdin>", line 1 SyntaxError: f-string: unterminated string >>>
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
In the format() syntax, one escapes curly braces by doubling them. It should probably be s=f'{a} "{{"'
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020