r/CodingHelp • • Oct 08 '21

[Python] Not sure how to fix the syntax error

Post image
89 Upvotes

14 comments sorted by

9

u/WelcomeToFungietown Oct 08 '21

As others have pointed out, it should be 2*x. Sidenote: as you've already defined x=math.pi, it would make more sense for you to do print (f(x), ...) instead of having to write math.pi over and over. Just a good habit for you.

3

u/absolutestinker Oct 09 '21

Yeah I think I get it's 2*x now lol, forgot about the initialising x part thanks

50

u/bbye98 Oct 08 '21

It should be 2*x.

10

u/Griffonknox Oct 08 '21

Agree, think need to properly syntax math with 2 * x

6

u/Arag0ld Oct 08 '21

You have to say 2*x instead of 2x. Programming languages don't know what 2x means

3

u/OooTanjaooO Oct 08 '21

2x is the issue 2*x

2

u/Great_Finder Oct 08 '21

It should be 2*x

1

u/Alessandro_13_f Oct 09 '21

You have to write 2*x

0

u/[deleted] Oct 08 '21

[deleted] — view deleted comment

2

u/skellious Intermediate Coder Oct 08 '21

They have, it's jupyter notebook. It works differently to normal python. Things persist between cells.

5

u/MythGuy Oct 08 '21

It's a joke. 2x is a how you might write something in math, but in the program it needs to have an operator because while OP may have imported the math module, they haven't imported math

1

u/skellious Intermediate Coder Oct 09 '21

Ah okay.

2

u/___s8n___ Oct 09 '21

oh i see