Python Forum

Full Version: Beginner Coding Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm brand new to Python and don't understand what I've done wrong here, could someone please enlighten me?
_______________________________________________________________________________________

Here's my code:

question_know = "How many sides does a square have?"
question = "How many sides does a circle have?"

if question == question_know:
    print("4")

else:
    print(f"I don't know, why not try asking {question_know}")
_______________________________________________________________________________________

Here's my error:

Error:
File "/Users/callumbennett/Dropbox/Mac/Documents/P Projects/HelloWorld/Playground.py", line 8 print(f"I don't know, why not try asking {question_know}") ^ SyntaxError: invalid syntax [Finished in 2.348s]
_______________________________________________________________________________________

Thanks for your time.
I don't see what is causing the syntax error with the code from looking at the picture.
Please post the actual code and the error in code tags as instructed above and not pictures of code.
Thanks for the fast reply to my issue, I have updated my post. Hope this is clearer.
Thank you I ran the code that you have now added above and I get no error, it outputs the following.
Output:
I don't know, why not try asking How many sides does a square have?
What version of python are you using, does it have f strings?
f strings where added in version 3.6 https://docs.python.org/3/whatsnew/3.6.h...g-literals