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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:18:09+00:00 2026-06-14T08:18:09+00:00

I am trying to read a list,values can be single or it can have

  • 0

I am trying to read a list,values can be single or it can have multiple entries seperated by a comma,my goal is to append href link for the first value in the list ,col[0] namely,am running into following compilation error

INPUT:-
cols=['409452,  12345', '', '', 'This a test python script']

EXPECTED OUTPUT:-
 <tr>
<td><a href=http://data/409452>409452,<a href=http://data/12345>12345</a></td>
<td></td>
<td></td>
<td>This a test python script</td>

Python code:-

  cols=cols=['409452,  12345', '', '', 'This a test python script']

TEMPLATE = ['  <tr>']
for col in cols:
    value = col.split(",")  
    TEMPLATE.append(
        '    <td><a href=http://data/{}> {}</a></td>'.format(value)
TEMPLATE.append('  </tr>')
TEMPLATE = '\n'.join(TEMPLATE)
print TEMPLATE


Output I am getting:-


TEMPLATE.append('  </tr>')
       ^
SyntaxError: invalid syntax
  • 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-14T08:18:10+00:00Added an answer on June 14, 2026 at 8:18 am

    In addition to the missing ) mentioned by others, your use of format is incorrect (need to use *value to have it look for items in the array). (Your definition of cols also has the wrong indentation and has an extra cols=.)

    This code works:

    cols=['409452,  12345', '', '', 'This a test python script']
    
    TEMPLATE = ['  <tr>']
    for col in cols:
        if "," in col:
            value = col.split(",")
            value[:] = ['<a href=http://data/{0}>{0}</a>'.format(id.strip()) for id in value]
            col = ','.join(value)
        TEMPLATE.append('    <td>{}</td>'.format(col))
    TEMPLATE.append('  </tr>')
    TEMPLATE = '\n'.join(TEMPLATE)
    print TEMPLATE
    

    Output:

      <tr>
        <td><a href=http://data/409452>409452</a>,<a href=http://data/12345>12345</a></td>
        <td></td>
        <td></td>
        <td>This a test python script</td>
     </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read a list of values from a text file, hello.txt
In Python, I'm trying to read the values on http://utahcritseries.com/RawResults.aspx . How can I
I'm trying to read a value from a list in a remote SharePoint site
I'm trying to read a list of strings from a file to an array.
I'm trying to read a list of items from a text file and format
In the code below i`m trying to read a list of selected projects and
I am trying to read in a text input file that contains a list
I am trying to compare a list of forbidden folders read from a file.
I'm trying to create a list of tasks that I've read from some text
Trying to read an RSS and select information using Linq but can't seem to

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.