[Tutor] SyntaxError Message

Pamela Wightley pamela.wightley at morgij.com.au
Tue Jul 8 03:41:33 CEST 2014


Hi All,

I have no programming experience and am trying to  teaching myself python. Am trying to replicate the code below but I get the error message below highlighted in yellow:

choice = input("Choose your option: ")
    if choice == 1:
        add1 = input("Add this: ")
        add2 = input("to this: ")
        print add1, "+", add2, "=", add1 + add2
    elif choice == 2:
        sub2 = input("Subtract this: ")
        sub1 = input("from this: ")
        print sub1, "-", sub2, "=", sub1 - sub2
    elif choice == 3:
        mul1 = input("Multiply this: ")
        mul2 = input("with this: ")
        print mul1, "*", mul2, "=", mul1 * mul2
    elif choice == 4:
        div1 = input("Divide this: ")
        div2 = input("by this: ")
        print div1, "/", div2, "=", div1 / div2
    elif choice == 5:
        loop = 0


Any assistance appreciated.

ERROR MESSAGE

>>> return input (1)
  File "<stdin>", line 1
SyntaxError: 'return' outside function
>>> return ("1")
  File "<stdin>", line 1
SyntaxError: 'return' outside function
>>> return input ("1")
  File "<stdin>", line 1
SyntaxError: 'return' outside function
>>> return input ("choose your option:")
  File "<stdin>", line 1
SyntaxError: 'return' outside function
>>> return input ("1:")
  File "<stdin>", line 1
SyntaxError: 'return' outside function
>>>


Pamela Wightley
[MorgijAnalytics e-sig][MorgijAnalytics e-apple]
Level 3 | 10 Bond Street |  Sydney | NSW 2000 | Australia
[P] (02) 8197 1828 |  [M] 0400 892 714  |
pamela.wightley at morgij.com.au<mailto:pamela.wightley at morgij.com.au>  |  www.morgij.com.au<http://www.morgij.com.au/> |   www.marqservices.com<http://www.morgij.com.au/>

The contents of this email and any attachments are strictly confidential and intended solely for the attention and use of the named addressee(s). If you are not the intended recipient you are not authorised to and must not disclose, copy, distribute, or retain this message without our authority. This email and all of its contents are subject to copyright. If you have received this email in error, please notify the sender by a return e-mail immediately. Please note that we do not accept responsibility for viruses and you should therefore scan any attachments.

[E-sig Green Message]


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140708/9c9d05c6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 9079 bytes
Desc: image001.png
URL: <http://mail.python.org/pipermail/tutor/attachments/20140708/9c9d05c6/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 5884 bytes
Desc: image002.png
URL: <http://mail.python.org/pipermail/tutor/attachments/20140708/9c9d05c6/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 2152 bytes
Desc: image003.jpg
URL: <http://mail.python.org/pipermail/tutor/attachments/20140708/9c9d05c6/attachment-0001.jpg>


More information about the Tutor mailing list