89 Topics

Member Avatar for
Member Avatar for dhani09

Hello, I have this home work question to be solved on a cloud ide: Create a class called ShoppingCart. Create a constructor that takes no arguments and sets the total attribute to zero, and initializes an empty dict attribute named items. Create a method add_item that requires item_name, quantity and …

Member Avatar for Emma Etigu
0
1,000
Member Avatar for gishi

hi! i want to place the contents of a dictionary into a csv file. Can someone help me with this? i already have the code in reading the csv file [CODE] import csv reader = csv.reader(open("c:\sample.dat")) for row in reader: print row [/CODE] i want the first element of the …

Member Avatar for Gribouillis
0
15K
Member Avatar for Saran_1

Here is the CSV file that I am working with: `"A","B","C","D","E","F","G","H","I","J" "88",18,1,"<Req TID=""34"" ReqType=""MS""><IISO /><CID>2</CID><MemID>0000</MemID><MemPass /><RequestData><S>[REMOVED]</S><Na /><La /><Card>[REMOVED]</Card><Address /><HPhone /><Mail /></ReqData></Req>","<Response T=""3"" RequestType=""MS""><MS><Memb><PrivateMembers /><Ob>0-12-af</Ob><Locator /></Memb><S>[REMOVED]</S><CNum>[REMOVED]</CNum><FName /><LaName /><Address /><HPhone /><Email /><IISO /><MemID /><MemPass /><T /><CID /><T /></MS></Response>",0-JAN-10 12.00.02 AM,27-JUN-15 12.00.00 AM,"26",667,0 "22",22,1,"<Req TID=""45"" ReqType=""MS""><IISO /><CID>4</CID><MemID>0000</MemID><MemPass /><RequestData><S>[REMOVED]</S><Na /><La /><Card>[REMOVED]</Card><Address /><HPhone /><Mail /></ReqData></Req>","<Response …

0
184
Member Avatar for BustACode

I found that one can use dictionaries to hold Tkinter widget config and display parameters. This then permits one to have these dictionaries elsewhere in the code for easy modification instead of buried within the code for each widget. I particularly like to place these dictionaries toward the top of …

0
2K
Member Avatar for vegaseat

Part 2 of exploring/tasting the Swift language takes a look at dictionaries; process flow controls like loops, if/else and switch/case; functions and sorting. I hope I can follow this up with part 3, a closer look at class operations.

Member Avatar for Lardmeister
2
507
Member Avatar for vegaseat

The example shows how to establish a dictionary of (row, column):value pairs to mimic a two dimensional array. This can be easily expanded to more dimensions. Python3 has dictionary comprehension, making the process of creating a dictionary of this type easier.

Member Avatar for vegaseat
1
7K
Member Avatar for BustACode

Note: In Python 2.7 use: `from __future__ import print_function` to use examples. In Python, by default, the key and value pairs in a dictionary are stored as hashes, therefore dictionaries do not retain the order in which values were added, and cannot be ordered. v_Dict ={} v_Dict["First"] = 99 v_Dict["Second"] …

Member Avatar for DragonMastur
1
465
Member Avatar for ogsirus

Hi guys, I am trying to write a program which picks the closest number possible out of a dictionary. The dictionary contains 50 doubles values, and I use a random double to pick the number i want to get the closest to if that makes sense. Currently I am using …

Member Avatar for ogsirus
0
852
Member Avatar for psvmr

I have been trying to create a program which the teacher log in to view the scores of a test of a school class. The scores are stored in a text file like this: Charlotte:7 Charlotte:4 Charlotte:3 Chelsea:2 Chelsea:9 Chelsea:5 Jeff:1 Jeff:10 As you can see there are multiple scores …

Member Avatar for vegaseat
0
667
Member Avatar for ogsirus

Hi Guys, Im a bit puzzled on the best way to store data which will later be saved to a csv. I am doing a record search on a database table which will get cycle through each employee and get the relevent information. Once I have done this I will …

Member Avatar for deceptikon
0
300
Member Avatar for Gribouillis

I uploaded a module named [symboldict](https://pypi.python.org/pypi/symboldict) to the python package index (pypi). This snippet shows how to use it to create a dictionary of symbols from various modules. This dictionary can be used as a common language shared by several modules. It can be used to load python libraries in …

Member Avatar for Gribouillis
4
515
Member Avatar for Sunil_12

Hello All, I am working on writing a code to implement dictionary in C++. I have few functions to implement for my dictionary. Can someone please help me writing the definitions for my dictionary. Header file and cpp file is attached here. **Dict.h file is as below:** enum WordType{All, Animal, …

Member Avatar for Sunil_12
0
262
Member Avatar for ddanbe

The idea for this snippet came from vegaseat, who wrote a very nifty RPN calculator in Python, simulating a switch/case statement, something that Python is missing. See this code on page 19 in the projects for beginners thread on the Python software development forum. In my opinion, he did a …

Member Avatar for xrjf
1
526
Member Avatar for kamilacbe

hi, I need to copy a dictionary to another dictionary where the Dictionary contains class data as value for eg I want to copy the data of object A1 to A2 .Thanks for your time. Class A { } Class B { } Main() { Dictionary<int,A> A1 = new Dictionary<int,A>(); …

Member Avatar for cgeier
0
247
Member Avatar for masterofpuppets

Here's a simple tutorial on dictionaries in Python: Dictionaries: Dictionaries are similar to other compound types except that they can use any immutable type as an index. One way to create a dictionary is to start with the empty dictionary and add items. The empty dictionary is denoted {}: [CODE]end2sp …

Member Avatar for Alf1#
5
998
Member Avatar for kxjakkk

file_spellcheck = input("Name of the document to be spell-checked: ") with open(file_spellcheck, "r") as i: spellchecking = i.read() for item in spellchecking: items = item.split() if items in with open("file.out", "w") as i: i.write() I need to make a spell checker that uses another file as a dictionary. So let's …

Member Avatar for vegaseat
0
271
Member Avatar for kxjakkk

I'm trying to create a program that will prompt the user for a list of text files to read from, then read those text files and build a dictionary of all the unique words found. Then finally put those unique words into another file and make it alphabetical order from …

Member Avatar for kxjakkk
0
636
Member Avatar for knan

I have a dictionary [CODE]dict1={'18':['4000','1234'],'12':['7000','4821','187','1860','123','9000']}[/CODE] I want to sort the keys and values such that, the output is, [CODE]dict1={'12':['123','187','1860','4821','7000','9000'],'18':['1234','4000']}[/CODE] I tried something! but it didn work [CODE]>>> for values in dict1: ... dict1[values].sort() ... >>> dict1 {'18': ['1234', '4000'], '12': ['123', '1860', '187', '4821', '7000', '9000']}[/CODE] Full sorting happens for …

Member Avatar for grantjenks
0
805
Member Avatar for 2014learner

I currently have five resx files in a XAML and C# application. I would like to convert the .resx files into their own resource dictionary. How do I do that by what code or website to look at? In the App.Xaml, xaml, and C# what is the process?

Member Avatar for ddanbe
0
144
Member Avatar for flebber

What I am trying to do is delete the key value pairs out of a dictionary if the value is = 0. I seem not to be acheiving that so far. Python 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more …

Member Avatar for flebber
0
415
Member Avatar for empuk2

Hello everybody...I'm new in C# programming but recently I have a problem and need to solve it. I hope you guys can help me. This problem only can solved with List and Dictionary. [CODE] using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ApplicantTestin { /// The DataObject class stored …

Member Avatar for walshregal
0
629
Member Avatar for vegaseat

Shows you how to create multiple Tkinter buttons in a loop, each with its own name, label and command response.

Member Avatar for CodingCabbage
2
1K
Member Avatar for vegaseat
Member Avatar for Gribouillis
4
868
Member Avatar for nikki05

Hi, I would like to to to store the Name and Items of ComboBox into dictionary. With the below code,I am able to store them. However, Name of ComboBox is as counting ComboBox10 to ComboBox1n. I would like to store Name of ComboBox as ComboBox1,ComboBox2 rather than ComboBox10 to ComboBox1n …

Member Avatar for nikki05
0
550
Member Avatar for nikki05

Hi I am storing name and texts of controls (Label, Button, ComboBox, ListBox, etc.) into a dictionary. With ContainsKey, I am able to find the texts of Labels, Buttons, and RadioButtons. However, I am getting problem to find the items of ComboBox. Appreciate if you have an idea. If _dic.ContainsKey(selectedControl.Name) …

Member Avatar for nikki05
0
223
Member Avatar for nikki05

Hi , I am able to add Label, button,texboxes into Dictionary. However I am getting problem to add values of Combobox into dictionary. Here is how I was trying to do. Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Try Dim myLabel As Label Dim myButton As Button …

Member Avatar for Reverend Jim
0
323
Member Avatar for Pallab.Bhk

Hey I have dictionary like following one dicts = {'met_293': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_394': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]'],'met_309': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_387': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]']} I want to remove keys which have same value like 'met_293' and 'met_309' those two keys have same value at 12th position which is '[KG]EHY' so i want my dictionary like this {'met_293': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_394': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]']} any …

Member Avatar for Pallab.Bhk
0
484
Member Avatar for vegaseat

This code example shows how to create a dictionary with row,column indexed (r,c) key tuples from a typical list of lists 2D matrix. Also an example is shown of the ease of processing the resulting dictionary.

Member Avatar for TrustyTony
5
6K
Member Avatar for lizaron

I have a data set like this data=[{u'a': u'D', u'b': 100.0, u'c': 201L, u'd': datetime.datetime(2007, 12, 29, 0, 0), u'e': datetime.datetime(2008, 1, 1, 6, 27, 41)},{u'a': u'W', u'b': 100.0, u'c': 201L, u'd': datetime.datetime(2007, 12, 29, 0, 0), u'e': datetime.datetime(2008, 2, 4, 6, 27, 41)},{u'a': u'W', u'b': 100.0, u'c': 202L, u'd': …

Member Avatar for zjtpjs4
0
270
Member Avatar for dirtydit27

Hello, I'm currently working on a homework problem that requires me to create a dictionary from a .txt file that contains some of the worst cars ever made. The file looks something like this: 1958 MGA Twin Cam 1958 Zunndapp Janus 1961 Amphicar 1961 Corvair 1966 Peel Trident 1970 AMC …

Member Avatar for snippsat
0
368

The End.