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 7493893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:13:37+00:00 2026-05-29T17:13:37+00:00

I am still new to Python and have been reviewing the following code not

  • 0

I am still new to Python and have been reviewing the following code not written by me.

Could someone please explain how the first instance of the variable “clean” is able to be be called in the check_arguments function? It seems to me as though it is calling an as yet undefined variable. The code works but shouldn’t that call to “clean” produce an error?

To be clear the bit I am referring to is this.

def check_arguments(ages):
    clean, ages_list = parse_ages_argument(ages)

The full code is as follows…

def check_arguments(ages):
    clean, ages_list = parse_ages_argument(ages)
    if clean != True:
        print('invalid ages: %s') % ages
    return ages_list

def parse_ages_argument(ages):
    clean = True
    ages_list = []
    ages_string_list = ages.split(',')
    for age_string in ages_string_list:
        if age_string.isdigit() != True:
            clean = False
            break
    for age_string in ages_string_list:
        try:
            ages_list.append(int(age_string))
        except ValueError:
            clean = False
            break

    ages_list.sort(reverse=True)
    return clean, ages_list

ages_list = check_arguments('1,2,3')
print(ages_list)
  • 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-05-29T17:13:38+00:00Added an answer on May 29, 2026 at 5:13 pm

    how the first instance of the variable “clean” is able to be be called in the check_arguments function?

    This is a nonsensical thing to ask in the first place, since variables aren’t called; functions are. Further, “instance” normally means “a value that is of some class type”, not “occurrence of the thing in question in the code listing”.

    That said: the line of code in question does not use an undefined variable clean. It defines the variable clean (and ages_list at the same time). parse_ages_argument returns two values (as you can see by examining its return statement). The two returned values are assigned to the two variables, respectively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing a bit of programming in Python (still a n00b at
I am new to python and have been working through the examples in Swaroop
Still new to python and django, though learning ;-) I have a view that
I'm new to Python and I have been trying to search through html with
still new to XML parsing with the iphone so i have a few questions.
I'm still new to the ASP.NET world, so I could be way off base
I'm still new to delegates and I've been playing with the Delegate-based Data Access
I am still new to LINQ, and I have wrestled with a query for
I'm fairly new to actual programming languages, and Python is my first one. I
I have just tried the following in Python 2.6: >>> foo = (set(),) >>>

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.