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

  • Home
  • SEARCH
  • 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 8616155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:33:03+00:00 2026-06-12T05:33:03+00:00

In Python, I am writing a script that will simulate a customer placing an

  • 0

In Python, I am writing a script that will simulate a customer placing an order. It will consist of creating the order, adding lines to it, and then checking out. I am currently doing it with something like:

api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
for apiName in apiList:
  #call API

I am designing this more as a framework so it would be easy to add new APIs in case things change. My design question is this: How can I code it so that I can call scanBarCode and addLine N number of times? Something like:

api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
numberOfLines = (random number)
for apiName in apiList:
  #call API
  #if API name is scanBarCode, repeat this and the next API numberOfLines times, then continue with the rest of the flow
  • 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-12T05:33:05+00:00Added an answer on June 12, 2026 at 5:33 am

    Something like the following should get you started:

    import random
    api = ['login', 'createOrder', 'scanBarCode', 'addLine', 'checkout']
    numberOfLines = random.randint(1, 10)   # replace 10 with your desired maximum
    for apiName in api:
        if apiName == 'scanBarCode':
            for i in range(numberOfLines):
                # call API and addLine
        else:
            # call API
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I amm writing a little python script that will grab information from VMs of
I'm writing a python CGI script that will query a MySQL database. I'm using
I'm writing a Python script that will automatically logon users from a list. This
I am writing a python script that will be doing some processing on text
I'm new to Python. I am writing a script that will numerically integrate a
I am currently writing a Python script for use on Linux machines that will
I'm writing a script in Python that will allow the user to input a
I am writing a python script that will parse through a file quickly by
I'm writing a script in Python that will spit out some data organized as
I am writing a python script (Linux) that is adding some shell aliases (writes

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.