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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:58:07+00:00 2026-05-13T08:58:07+00:00

I am trying to enter list items into a string. I then want to

  • 0

I am trying to enter list items into a string. I then want to store the string as a variable and print it out in another function. The code I have got so far is:

def b(): 

    ID = [0, 1, 2]
    ID2 = 'ID={0}.{1}.{2}'.format(*ID) 
    return ID2 

if __name__ == '__main__': ID2 = b() 


def c(ID2): 
    print ID2 

if __name__ == '__main__': myObject = c(ID2) 

The output I get is:

[0, 1, 2] 

Any help would be appreciated. Thanks

I was returning the list as well as ID2. This was causing the problem. Sorry about this.

The code is now working. Thanks

  • 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-13T08:58:07+00:00Added an answer on May 13, 2026 at 8:58 am
    def b():
        ID = [0, 1, 2]
        ID2 = ('ID=%d.%d.%d' % tuple(ID))
        return ID2
    
    if __name__ == '__main__': ID2 = b()
    
    def c(ID2):
        print ID2
    
    if __name__ == '__main__': myObject = c(ID2)
    

    works for me, don’t have python3 handy so cannot try with the .format()-syntax.

    However myObject = c(ID2) does not make sense, function c() does not return anything

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

Sidebar

Related Questions

I am trying to create a linked list where you can enter items into
I am trying to create a list where I want users to enter data
I am trying to get the Enter key to trigger a function when it
I am trying to ignore the enter key, but i do not want to
enter code here I am trying to write a query to extract all rows
As the title implies I'm trying to select items from one list box, press
I am trying to filter a list of items in a ListView as the
I am trying to only have the words print out if they occur the
What I'm trying to do is ask the user for a list of items,
I am trying to provide the user with a list of items in a

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.