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

The Archive Base Latest Questions

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

So I have written a procedure to format a list that I have in

  • 0

So I have written a procedure to format a list that I have in Python to be written in an HTML form as JavaScript. it looks like this

from django.template.defaultfilters import slugify
def js_format(cars):
   new_cars = []
   for car in cars:
       car = str(slugify(car))+'|'+car
       new_cars.append(car)
   return new_cars

dodge = ["Avenger","Caliber","Caravan","Challenger","Colt","D150","D250","D350","Dakota","Dart","Daytona","Durango","Durango Hybrid","Dynasty","Grand Caravan","Intrepid","Journey","Magnum","Monaco","Neon","Nitro","Omni","Raider","Ram 1500","Ram 2500","Ram 3500","Ram 50","Ram Van","Ram Wagon","Ramcharger","Shadow","Sprinter","SRT Viper","Spirit","Stealth","Stratus","Viper","W150","W250","W350"]

when I use the procedure on the ‘dodge’ list…

>>> js_format(dodge)
['avenger|Avenger', 'caliber|Caliber', 'caravan|Caravan', 'challenger|Challenger', 'colt|Colt', 'd150|D150', 'd250|D250', 'd350|D350', 'dakota|Dakota', 'dart|Dart', 'daytona|Daytona', 'durango|Durango', 'durango-hybrid|Durango Hybrid', 'dynasty|Dynasty', 'grand-caravan|Grand Caravan', 'intrepid|Intrepid', 'journey|Journey', 'magnum|Magnum', 'monaco|Monaco', 'neon|Neon', 'nitro|Nitro', 'omni|Omni', 'raider|Raider', 'ram-1500|Ram 1500', 'ram-2500|Ram 2500', 'ram-3500|Ram 3500', 'ram-50|Ram 50', 'ram-van|Ram Van', 'ram-wagon|Ram Wagon', 'ramcharger|Ramcharger', 'shadow|Shadow', 'sprinter|Sprinter', 'srt-viper|SRT Viper', 'spirit|Spirit', 'stealth|Stealth', 'stratus|Stratus', 'viper|Viper', 'w150|W150', 'w250|W250', 'w350|W350']

Everything is formatted the way I would like except I need each item in the list to be in double quotes. I don’t know how to change the quotation marks in python because python recognizes single quoted and double strings equally. Any help would be appreciated.

Thank you for viewing my question

  • 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-15T04:11:23+00:00Added an answer on June 15, 2026 at 4:11 am

    Use json.dumps() to create Javascript literals:

    def js_format(cars):
       new_cars = ['{0!s}|{1}'.format(slugify(car)), car) for car in cars]
       return json.dumps(new_cars)
    

    This will generate a full JS list with properly quoted strings:

    >>> js_format(dodge)
    '["avenger|Avenger", "caliber|Caliber", "caravan|Caravan", "challenger|Challenger", "colt|Colt", "d150|D150", "d250|D250", "d350|D350", "dakota|Dakota", "dart|Dart", "daytona|Daytona", "durango|Durango", "durango-hybrid|Durango Hybrid", "dynasty|Dynasty", "grand-caravan|Grand Caravan", "intrepid|Intrepid", "journey|Journey", "magnum|Magnum", "monaco|Monaco", "neon|Neon", "nitro|Nitro", "omni|Omni", "raider|Raider", "ram-1500|Ram 1500", "ram-2500|Ram 2500", "ram-3500|Ram 3500", "ram-50|Ram 50", "ram-van|Ram Van", "ram-wagon|Ram Wagon", "ramcharger|Ramcharger", "shadow|Shadow", "sprinter|Sprinter", "srt-viper|SRT Viper", "spirit|Spirit", "stealth|Stealth", "stratus|Stratus", "viper|Viper", "w150|W150", "w250|W250", "w350|W350"]'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a SQL Server stored procedure that includes a DateTime parameter. This
I have written a procedure that shows me the image path from picture table
I have written a stored procedure that, yesterday, typically completed in under a second.
I have written grammar for a language (sample code below) //this is a procedure
I have written this code inside a servlet to delete certain records from three
I have written this code in JavaScript and works perfectly fine when I include
I have written a stored procedure, & to execute this procedure I need to
I have written a Stored procedure which return some fields from a temporary table
I have a procedure written in PLJava that sends out updates over JMS in
I have written a package that has a stored procedure and a REF cursor.

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.