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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:08:32+00:00 2026-06-11T15:08:32+00:00

Lets say I have a list: my_list = [‘first’, ‘second’, ‘third’] Now what I

  • 0

Lets say I have a list:

my_list = ['first', 'second', 'third']

Now what I want to do is run a cmd command that defines a name to this list, but at the same time numbers it. I know this sounds confusing so here is what it would look like:

for i in range (0, 4):
      localdevice = cmd("some command create name ARRAY_456_" + i + "")

Now I don’t need the command itself, that I already have, what I need to know is whether my for loop will work and create ARRAY_456_1 then ARRAY_456_2 and then ARRAY_456_3?

Or is there some other way that I can add numbers to the end of 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-11T15:08:33+00:00Added an answer on June 11, 2026 at 3:08 pm

    Should work but would write it that way

    for i in range (0, 4):
          localdevice = cmd("some command create name ARRAY_456_%d" % i)
    

    Using string concatenation isn’t that clean. Using format to replace parameters in a string is much more flexible

    Here’s a more complete example:

    cmd = 'some command create name'
    for i in range(4):
        name = 'ARRAY_456_%d' % i # will create ARRAY_456_0, ...
        localdevice = cmd('%(cmd)s %(name)s' % dict(cmd=cmd, name=name)) # will merge the command with the name using keywords
    

    If it’s not what you’re looking for then. I’m not sure to understand the question.

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

Sidebar

Related Questions

lets say I have a list like so: ['one','two','three','four','five','six','seven','eight','nine'] and I want to experiment
Lets say I have a list: L = [15,16,57,59,14] The list contains mesurements, that
Lets say I have a list of 1,000,000 users where their unique identifier is
Lets say i have the following unordered list <ul> <li><a>Hank</a></li> <li><a>Alice</a></li> <li><a>Tom</a></li> <li><a>Ashlee</a></li> </ul>
Lets say a have the following Model public class FirstModel { public List<SecondModel> SecondModels
Lets say I have a database of widgets. I am showing a list of
Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
I have a list of items lets say for example a, b, c. As
I have a ListBox bound to a list of Items (for arguement, lets say
Right now, lets say I have code much like this... $some_var=returnsUserInput(); function funcA($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.