[Tutor] how do I set variables in Python 3.4
Steven D'Aprano
steve at pearwood.info
Sun Jul 13 07:59:59 CEST 2014
Hi Danielle, and welcome.
Others have already replied to your post, and I'm going to reply with
pretty much the same answer:
Please help us to help you! We're not mind-readers, we need to see the
actual error messages you get, and your actual code, not just a rough
paraphrase of it.
When Python has an error to report, it will print a traceback like this:
py> x = 1
py> y = 1/(1-x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
It's important to copy and paste the whole traceback, starting with the
first line "Traceback ..." to the end. Tracebacks often contain a lot of
useful information to help debugging. (Although not always: one of the
frustrations of programming is that sometimes the error messages aren't
very useful.)
You say:
> I am supposed to use operand1=2 and operand2=7
You should be able to use that *exactly* as it is (although putting
spaces around the = sign is recommended):
py> operand1 = 2
py> operand2 = 7
py> result = operand1 + operand2
py> print(result)
9
> To complete: result= operand1+operand2 etc, but I keep getting invalid
> syntax either on the " or operand1. Please help
We can't tell what you have mistyped if we don't know what you typed in
the first place :-(
Regards,
Steve
On Thu, Jul 10, 2014 at 10:50:12PM -0700, Danielle Salaz wrote:
> I'm a noob to Python and cannot figure out how to complete one of my assignments.
>
> I am supposed to use operand1=2 and operand2=7
> To complete: result= operand1+operand2 etc, but I keep getting invalid syntax either on the " or operand1. Please help
>
> Sent from my iPhone
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list