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

The Archive Base Latest Questions

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

#!/usr/bin/python -tt # A dictionary Of Each New SSID WirelessNetwork = {} WirelessNetwork[‘name’] =

  • 0
#!/usr/bin/python -tt

# A dictionary Of Each New SSID
WirelessNetwork = {}
WirelessNetwork['name'] = 'baz'
WirelessNetwork['type'] = 'bar'
WirelessNetwork['pass'] = 'foo'

# A list of all SSIDs
networkAddList = (WirelessNetwork)

def addWireless(passedDict={}):
  print 'Adding SSID: %s' % passedDict['name']
  print 'Of type: %s' % passedDict['type']
  print 'With Password: %s' % passedDict['pass']

for networkDict in networkAddList:
  addWireless(networkDict)

So I have a List “networkAddList” full of dictionaries ,i.e. “WirelessNetwork”.
I want to iterate that list “for networkDict in networkAddList”
and pass the dictionary itself to my function “addWireless”

When I run the sample code above I get the following error:

TypeError: 'string indices must be integers, not str'

Which makes me think that python thinks passedDict is a string, thus thinking I want string indices i.e. 0 or something rather then the key ‘name’. I’m new to python but I am going to have to do this kind of thing a lot so I hope somebody can point me in the right direction as I think its pretty simple. But I can’t change the basic idea , i.e. a list of dictionaries.

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

    When debugging in python you can confirm your suspicion that the value being passed is a string with the type function:

    print type(passedDict)
    

    When you create your tuple with one element, you need a trailing “,”. Also note that a tuple is different from a list in python. The primary difference is that tuples are immutable and lists are not.

    #!/usr/bin/python -tt
    
    # A dictionary Of Each New SSID
    WirelessNetwork = {}
    WirelessNetwork['name'] = 'baz'
    WirelessNetwork['type'] = 'bar'
    WirelessNetwork['pass'] = 'foo'
    
    # A list of all SSIDs
    networkAddList = (WirelessNetwork,)
    
    def addWireless(passedDict={}):
      print 'Adding SSID: %s' % passedDict['name']
      print 'Of type: %s' % passedDict['type']
      print 'With Password: %s' % passedDict['pass']
    
    for networkDict in networkAddList:
      addWireless(networkDict)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/bin/python class Bar(object): @staticmethod def ruleOn(rule): if isinstance(rule, tuple): print rule[0] print rule[0].__get__(None, Foo)
The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
#!/usr/bin/python #this looks for words in dictionary that begin with 'in' and the suffix
I have the following Python code: #!/usr/bin/env python2.6 class container(object): name = 'container' configuration
Let's say I have a basic Python script, test.py : #!/usr/bin/python print Content-type: text/html\n\n
I have a simple hello world python script: #!/usr/bin/python print Content-Type: text/html print print
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import Tkinter import twitter class simpleapp_tk(Tkinter.Tk): def __init__(self,parent):
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import Tkinter class simpleapp_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent=parent
I'm writing a simple alarm utility in Python. #!/usr/bin/python import time import subprocess import
Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append(/home/username/python/flup) sys.path.append(/home/username/python/django) # more path

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.