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

The Archive Base Latest Questions

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

for line in f.readlines(): (addr, vlanid, videoid, reqs, area) = line.split() if vlanid not

  • 0
     for line in f.readlines():
     (addr, vlanid, videoid, reqs, area) = line.split()

     if vlanid not in dict:
          dict[vlanid] = []

     video_dict = dict[vlanid]

     if videoid not in video_dict:
         video_dict[videoid] = []

     video_dict[videoid].append((addr, vlanid, videoid, reqs, area))

Here is my code, I want to use videoid as indices to creat a list. the real data of videoid are different strings like this : FYFSYJDHSJ

I got this error message:

video_dict[videoid] = []
TypeError: list indices must be integers, not str

But now how to add identifier like 1,2,3,4 for different strings in this case?

  • 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-27T18:13:59+00:00Added an answer on May 27, 2026 at 6:13 pm

    Don’t use dict as a variable name. Try this (d instead of dict):

    d = {}
    for line in f.readlines():
        (addr, vlanid, videoid, reqs, area) = line.split()
        video_dict = d.setdefault(vlanid, {})
        video_dict.setdefault(videoid, []).append((addr, vlanid, videoid, reqs, area))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have example: for line in IN.readlines(): line = line.rstrip('\n') mas = line.split('\t') row
text_file = open("new.txt", "r") lines = text_file.readlines() for line in lines: var1, var2 =
Am I being dense here? StreamReader.ReadLine states that: A line is defined as a
Line 3 of the code below fails if I omit the => $v portion.
line = english: while french: pendant que spanish: mientras german: whrend words = line.split('\t')
I frequently write code like: lines = open('wordprob.txt','r').readlines() words = open('StdWord.txt','r').readlines() i = 0
Another question. This program counts and numbers every line in the code unless it
from mechanize import Browser br = Browser() br.open('http://somewebpage') html = br.response().readlines() for line in
The code below worked fine until I added the regex line. When I comment
Having this code p = subprocess.Popen('tail -f /var/log/syslog', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in

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.