15,175 Topics
| |
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 … | |
I was trying to calculate the angle between two points using math.atan2(y, x) as was suggested in numerous forums and tutorials. After trying it myself, it didn't quite work as charmingly as it did for others. So I made a simple example of what it does and I need some … | |
Hello everyone How can i make the button be on the left side or right side please Part of the code Button(self, text = "start", command = self.launch).grid(row = 7, column = 0, columnspan = 1,) Thanks in advance | |
I am trying to make a system for my game in which the player's enemy has a decreasing amount of health. My shell output is here: Cannon Fired! Enemy Health= 8 Cannon 1 ammo = 10 The enemy fired back! Your health is now 12 Fire your choice of cannon! … | |
In my game, I am trying to make it so when the enemy's health equals 0, the player advances. I used a while statement and a true or false variable. When the enemy health is less than or equal to 0, the program exits the while statement. It does not … | |
In a combat system, how would I have a certain raw_input repeat until the enemy is dead? | |
Hello everyone I'm building my first app using Python TkInter and i would like to have someone help me with this I want to make a checkbox by default it should be False (Unchecked) And make it do something like (Sorry i only know how to do it on visual … | |
Is there a way to keep a global throughout multiple def statements? | |
I need some help for python AI. I can't understand some codes for python AI. I need to understand this code. So please help me. code : def __str__(self): if self.nature is 'AI': return self.name+' ('+self.nature+')'+' as '+self.colour else: return self.name+' as '+self.colour In this code 'AI' is used. But … | |
I am creating a pokemon text-based game. I have 1 problem, I dont know how to do the attacks. I thought - enemyHP = 100 class pikachu: def slamAttack(self): self.enemyHP = enemyHP - 30 print("pikachu used slam!") print(enemyHP) #then to call it when they ask for slam attack = str(input("OPTIONS: … | |
Hey, I m writting this python program and I need to have the user enter a password. As with all passwords, if it is correct then the program proceeds. if not, then it halts there. What code should I use for this? | |
i don't know anything about django.. but i want like google while we are searching data in one tab and if we open new tab we getting new search page... am doing one task in my office but if i open new pageam getting last saved values.. so please help … | |
im trying to get this script to draw a line from the center of the rectangle to the mouse BUT i only want it to draw about 10 pixels out. how can i find that point that is 10 pixels(or points) out? code so far: import pygame from pygame.locals import … | |
My opensuse 12.came with python 2.72 installed. How can I update that and two, which editor would be reccomended? Thanks but please this is my first attempt at linux | |
When I run: [code]dec = 255 print hex(dec) [/code]I get 0xff, but I like to get just 'ff' | |
There are precious few archaeologists in Japan, and only a handful who produce their own software programs to analyze geographic information. One who does is Professor [Izumi Niiro](http://www.okayama-u.ac.jp/user/arch/about/niiro.html) of the Okayama University. A convert from Perl, Professor Niiro now uses Python to perform data analysis via the Geographic Resources Analysis … | |
| hi, I want to load an unknown number of buttons (20 max) into a panel. When clicking a button, some other code should be executed. Below code shows my attempt at solving the problem. Unfortunately execution results in an assertion error. Any help in pointing me in the right direction … |
Given: A string s of length at most 200 letters and four integers a, b, c and d. Return: The slice of this string from indices a through b and c through d (with space in between), inclusively. | |
Guys! I would like to know if it was possible to create an assembler using python since it has excellent string handling features. Any Ideas how it could be done? | |
i have a text document 'topics.txt': 1~cocoa 2~ 3~ 4~ 5~grain~wheat~corn~barley~oat~sorghum 6~veg-oil~linseed~lin-oil~soy-oil~sun-oil~soybean~oilseed~corn~sunseed~grain~sorghum~wheat 7~ 8~ 9~earn 10~acq and so on.. here the numbers correspond to the file names, i have about 20000 files. import os import re import sys sys.stdout=open('f1.txt','w') from collections import Counter from glob import glob def removegarbage(text): text=re.sub(r'\W+',' … | |
I compiled a program in python, but the second I open it, there is a flash of the error, but then the cmd window closes. | |
I have 2 functions, one of which works and one of which doesn't. I do not understand this, because the only difference is that the second function puts in just the name of the variable, where the 1st function puts in the value. There is only one line to build … | |
I have to create a python program for class- the instructions are- Write a payroll program that pays time and a half for anything over 40 hours. This should have 3 functions in #addition to main. Which I did without the 3 funcitons. def main(): hours = float(input('How many hours … | |
Hello guys, Please how can I read xml files and extract image store in it and save it as .jpeg in a specified folder. Also how to export all the other fields to .csv or .txt file. Thank you. | |
I have a csv that needs to be put into a database format so I can sort and count the data. My approach has been to use python csv and sqlite modules. I am communicating with the database and creating one of the 2 tables. Second table has many more … | |
import os import re import sys sys.stdout=open('f1.txt','w') from collections import Counter from glob import glob def removegarbage(text): text=re.sub(r'\W+',' ',text) text=text.lower() return text folderpath='d:/induvidual-articles' counter=Counter() filepaths = glob(os.path.join(folderpath,'*.txt')) num_files = len(filepaths) with open('topics.txt','r') as filehandle: lines = filehandle.read() words = removegarbage(lines).split() counter.update(words) for word, count in counter.most_common(): probability=count//num_files print('{} {} {}'.format(word,count,probability)) … | |
Hi all, First, I do not know what is the appropriate forum, here or in Python forum!! I am new user in Ubuntu and I want install Python to complete installation other program. After I downloaded Python version 2.7.5 , and uncompress the file in the my folder, I go … | |
Hi All, Using pydbg I'm opening certain files(ex. c:\\myfile.txt) within a win32 application(Ex. c:\\notepad.exe) in this way. dbg = pydbg() dbg.load("c:\\notepad.exe", "c:\\myfile1.txt") So my question is, if the target application(Ex. c:\\notepad.exe) is already running then,then is it possible to open a another file(For example c:\myfile2.txt ) within the same application … | |
Hy, I have a beginner question: when using PyDev should all my programs be inside a package or not? | |
Hi How to get the path of home directory in windows? I have the script that write log.txt in my windows 7 Desktop. How can I change path in python to write log.txt in homedir directory? Is there any way to do it? I tried with those 2 methods But … |
The End.