• Register
search
Log In

Recent questions tagged dictionary

0 votes
1 answer 5 views
Problem: Hello, experts. I am a new Python learner. I’ve been learning computer programming since last week. I am learning new things every single day. Today, I have got a problem when working with a python dictionary. I’ve created a Python dictionary. For example: ... to you, but it needs to be answered badly. I am looking forward to hearing from you, mate. Thanks for your kind help.
asked 4 days ago adamSw 9.9k points
1 vote
1 answer 10 views
Problem: Hello kodlogs, I am new to python programming just completed the basic core part in python and wanted to implement the python dictionary concept Basically I wanted to implement the addition of two dictionary but I am getting error don't know what I am doing ... 3, in Merge return(dict2.add(dict1)) AttributeError: 'dict' object has no attribute 'add' Waiting for the reply from someone.
asked Jul 1 Gavin 15.2k points
1 vote
1 answer 12 views
Problem: I have a dictionary that consists of: Dict = {     "Krishna" : 79,     "Arnav" : 46,     "Paulo" : 90,     "Christian" : 77,     "Renartovic" : 33,     "Wanda" : 65,     "Arteta" : 80,     "Santiago" : 68,     "Jovic" : 88     } I ... compiling this program:   File "val.py", line 13     if "Wanda" in Dict:     ^ IndentationError: unexpected indent Can anyone help me to solve this error?
asked Jun 7 samhaz 5k points
1 vote
1 answer 14 views
Problem: I have some knowledge of PHP. I am just trying to learn the use of call_user_func function in PHP but I am only facing below error if I try to run following very basic code: Please find below the error which I am facing for your kind reference: ... as expected but here I am trying to refer to my class's printHiMartin and unable to understand why my "this" is not being registered.
asked May 23 Martin K 6.6k points
1 vote
1 answer 30 views
Problem: For this following two dictionaries: firstdictionary = {'x': 112, 'y': 224, 'z': 448} secoenddictionary = {'x': 56, 'y': 28, 'z': 14} I wrote a pyhton program to subtract their values: firstdictionary = {'x': 112, 'y': 224, 'z' ... - secoenddictionary} TypeError: unsupported operand type(s) for -: 'dict' and 'dict' Does any one have any solution for this error? Thanks in advance
asked May 14 samhaz 5k points
1 vote
1 answer 22 views
Problem: I have two dictonaries: firstdictionary = {'x': 112, 'y': 224, 'z': 448} secoenddictionary = {'q': 56, 'w': 28, 'e': 14} I wrote a python program to add this two dictionaries: def Addition(firstdictionary, secoenddictionary): return(firstdictionary ... : 'dict' object has no attribute 'add' Is there any problem in my code and how can I add two dictionaries using python program?
asked May 14 samhaz 5k points
1 vote
1 answer 113 views
Problem : I am very new to Django. My current task is to store the form field variable with the help of Django cache and I have already added the Django form in my view. I am often facing below error and as I am very new to Django so unable to understand the below ...         form = Formulary() return render(request, 'form.html', {'form' : form}) I am looking for Django expert to fix above error.
asked May 1 stewart 4k points
2 votes
1 answer 9 views
Problem: I was trying to find the first repeated word in a string in python using dictionary. So I wrote this code which give me error. def whichRepeat(input): words = input.split(' ') dict = words for key in words: if dict[key]>1: print (key) return if __name__ == ... "main.py", line 10, in whichRepeat if dict[key]>1: TypeError: list indices must be integers or slices, not str How to solve this?
asked Apr 28 samhaz 5k points
1 vote
1 answer 11 views
Problem: Supose, I have two existing dictionaries which are: Supplier_chain = {'Chilox' : 1546, 'TakeOut' : 890, 'Alfredos' : 1342, 'Snacks' : 150 } Consumer_chain = {'Snacks' : 150, 'Fritata' : 1889, 'Pasterios' : 1467, 'Alfredos' : ... : unsupported operand type(s) for -: 'builtin_function_or_method' and 'builtin_function_or_method' Can anyone sort out this problem and help me to solve this?
asked Apr 26 samhaz 5k points
1 vote
1 answer 10 views
Problem: I wrote a python program to check whether a given key already exists in a dictionary. The dictionary I have is: (If exists, print Key is present and the value of the key. Otherwise print key is not present .) {'a': 233, 'b':588, 'c':967 ... checkKey() missing 1 required positional argument: 'key' Whats the problem with my program can any one help me to sort this out? Thanks in advance.
asked Apr 26 samhaz 5k points
1 vote
1 answer 21 views
Problem : I was trying to check if key exists in dictionary python. So I wrote this code: def isEmpty(self, dictionary): for element in dictionary: if element: return True return False def onMessage(self, socket, message): if self.isEmpty(self.users) == False ... unindent does not match any outer indentation level What is the problem in this program and how can I check if key exists in dictionary?
asked Apr 26 samhaz 5k points
1 vote
1 answer 17 views
Problem: I tried to check my dictionares using if the dictionary is in use or not. To check that I wrote something like: def isEmpty(self, dictionary): for element in dictionary: if element: return True return False def onMessage(self, socket, message): if self.isEmpty(self.users ... : socket.send("ONLINE " + ' ' .join(self.users.keys())) But the program is not working properly what should I do?
asked Apr 3 LizzyM 5.7k points
1 vote
1 answer 25 views
Problem: I am a beginner in programming language and I choose python for this.So I was doing my programming practice. I was looking for a way to convert list to dictionary python. It should applicable. Thank you
asked Apr 2 LizzyM 5.7k points
1 vote
1 answer 14 views
Problem: I am beginner in pyhton programing. I have a dictionary of string and int and that is: Dictionary = { "Hola": 65, "tart" : 32, "star" : 34, "site" : 55, "pearl" : 88 } Supose I have to remove a key from this dictionary what should I do next.
asked Mar 28 LizzyM 5.7k points
3 votes
1 answer 10 views
Problem: Hi all, I am trying to figure out the dictionary related problems in python. Dictionary is really fun to learn and work with. Let’s say, I have a dictionary dict = {'1': 'one', '3': 'three', '2': 'two', '5': 'five', '4': 'four'} If ... needed to check every value inside the dictionary what can I do for that? So, I want to know how to check if a value is in a dictionary python?
asked Mar 24 Gavin 15.2k points
2 votes
1 answer 26 views
Problem: Hello good soul, I am a newbie in python programming. I am having a problem printing both the name on the list and the email. Let me put it this way, I want to write a for loop to print each contact in contact_emails. Any solution will be much appreciated. Thanks.
asked Mar 17 Gavin 15.2k points
0 votes
1 answer 16 views
I am new to python programming I was trying to check if a letter is uppercase in python. I wrote some code to check this statement : import string def UpperCase(s_str): for x in s_str: if x not in string.UpeerCase: return False return True But I can not get the actual ... last): File "<stdin>", line 1, in <module> NameError: name 'LoWWE' is not defined Can anyone help me to solve this thing?
asked Mar 14 LizzyM 5.7k points
0 votes
1 answer 21 views
I wrote a code to check if a dictonary is empty or not. I wrote this code in python : def isEmpty(self, dictionary): for element in dictionary: if element: return True return False def onMessage(self, socket, message): if self.isEmpty(self.users) == False: socket.send("No ... : socket.send("ONLINE " + ' ' .join(self.users.keys())) Does my isEmpty returns true and is there any problem in my code.
asked Mar 11 LizzyM 5.7k points
1 vote
1 answer 20 views
Problem: I am starting writing code in python. I wanted to test if a key exists in a dictionary before updating the value for the key. I wrote the following code: if 'key1' in dict.keys(): print "Present" else: print "Thanks" If there any other way to check this, please let me know.
asked Mar 10 Gavin 15.2k points
0 votes
1 answer 21 views
Problem : I am new to C#. I want to know how can I get the value of a given key in a following exception which I am currently facing in C# in a way it affects all the generic classes? Below is the exception which I am currently facing. "The given key was not present in the dictionary." How to fix above exception.
asked Feb 24 mphil 2.3k points