I have the following code in Python 3
def inputWithDefault(text:str, default):
result = input(f"{" " * int(len(text))}{default}\r{text}")
return default if not(result is type(default)) else result
Python says this when in the syntax-tree generation stage
File "main.py", line 2
result = input(f"{" " * int(len(text))}{default}\r{text}")
^
SyntaxError: f-string: expecting '}'
This is difficult to work through as the error is unclear and its reasoning is difficult to parse, I have checked and the {} match up throughout the fstring declaration.
f"{"does not contain a closing}. You have two string literals there and thefapplies only to the first. I can't really tell what you're trying to do or why you wrote it as two separate string literals, so I can't advise you further on that.f-stringhas nested double quotes:". You need python 3.12 or better to parse that.input()is irrelevant to the problem.) For tips, see How to Ask.result is type(default)will never be true becauseresultis always a string, never a type. If you want an actual (editable) default value toinput(), see Show default value for editing on Python input possible? or (non-editable) How to define default value if empty user input in Python?