Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:11:15+00:00 2026-06-14T17:11:15+00:00

I am learning python and this is from http://www.learnpython.org/page/MultipleFunctionArguments They have an example code

  • 0

I am learning python and this is from

http://www.learnpython.org/page/MultipleFunctionArguments

They have an example code that does not work- I am wondering if it is just a typo or if it should not work at all.

def bar(first, second, third, **options):
    if options.get("action") == "sum":
        print "The sum is: %d" % (first + second + third)

    if options.get("return") == "first":
        return first

result = bar(1, 2, 3, action = "sum", return = "first")
print "Result: %d" % result

Learnpython thinks the output should have been-

The sum is: 6
Result: 1

The error i get is-

Traceback (most recent call last):
  File "/base/data/home/apps/s~learnpythonjail/1.354953192642593048/main.py", line 99, in post
    exec(cmd, safe_globals)
  File "<string>", line 9
     result = bar(1, 2, 3, action = "sum", return = "first")
                                                ^
 SyntaxError: invalid syntax

Is there a way to do what they are trying to do or is the example wrong? Sorry I did look at the python tutorial someone had answered but I don’t understand how to fix this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:11:16+00:00Added an answer on June 14, 2026 at 5:11 pm

    return is a keyword in python – you can’t use it as a variable name. If you change it to something else (eg ret) it will work fine.

    def bar(first, second, third, **options):
        if options.get("action") == "sum":
            print "The sum is: %d" % (first + second + third)
    
        if options.get("ret") == "first":
            return first
    
    result = bar(1, 2, 3, action = "sum", ret = "first")
    print "Result: %d" % result
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning python and have this error . I can figure out where\what
I have been learning python for some time now. While starting this learning python
I am learning Python for the past few days and I have written this
Hello Guys! I started learning python GUI development. Let's say I have this script:
I have this very simple python code to read xml for the wikipedia api:
I have been here for a couple of months learning python from examples, but
I'm learning Python, and I'm having trouble with this simple piece of code: a
allow me to preface this by saying that i am learning python on my
After learning python (cpython) and using this page to search for tkinter widgets' options,
I am learning Python, and I have written a script per an example in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.