15,190 Topics

Member Avatar for
Member Avatar for tdeck

Ideally I'd like to do it with a list comprehension. Something like this [CODE]result = [(key, value)for key in dict.keys(), value in dict.values()][/CODE] but clearly that isn't the right format. Any suggestions? EDIT: This seems like what I want to do, but it doesn't work: [CODE]result = [(dict.keys[i], dict.values[i]) for …

Member Avatar for jlm699
0
324
Member Avatar for logon84

i am a beginner. i have no idea how i can make Tic Tac Toe game. please help me. Question #1 Extend program To use arrays For a 5*5 Tic Tac Toe game. (wins are 5 Horizontal, 5 Vertical, 5 Diagonal) Question #2 Extend to 4*4 array (But wins are …

Member Avatar for manathisbest
-2
169
Member Avatar for chavanak

Hi, I am comparing 2000 files with one other file. I want the program to go through each line in both files and compare. If the line is present, then it has to write to another file. What I tried was to open both the files and use readlines() to …

Member Avatar for chavanak
0
423
Member Avatar for newportking

I am interested in learning python and picked up a friends textbook to try and work through it. I have no cs experience so am pretty clueless. I am having difficulty with one of the problems in the first chapter lol. i am trying to make the program spit out …

Member Avatar for newportking
0
115
Member Avatar for P00dle

Hi, I have stumbled on an interesting problem. I have thought 'n' thought, but haven't come up with any good ideas of how to handle this. I have a text file that contains many records, but without the records being seperated. I need to figure out how to seperate these …

Member Avatar for jlm699
0
310
Member Avatar for nerdagent

How would I limit mouse movement in python? For example I have a 480x480 grid where each block is 30. If I click on a block I would like to only be able to click in an area of one block around the block that I placed.

Member Avatar for ov3rcl0ck
0
78
Member Avatar for python.noob

Hello friends, I've tried to install wxwidgets in my mandriva 2009 spring for GUI interaction with python. In the installation instruction it said that i need gtk+ library. So i downloaded GTK+. When i configured GTK+ i got the message checking for BASE_DEPENDENCIES... configure: error: Package requirements (glib-2.0 >= 2.21.3 …

Member Avatar for Gribouillis
0
192
Member Avatar for SMIFMD

Greetings! I am in need of some techincal assistance. My problem is as follows: In my Programming class, we are starting to use the graphics package in Python. We are using a module called graphics.py In order to use this module, we have to save it to the desktop and …

Member Avatar for Gribouillis
0
2K
Member Avatar for sravan953

Hey All, I have been asked to do a project on Java at school. We are still learning it at an elementary level... Many decided to do the project on things like ticket booking, banking and stuff... whereas I wanted to do something innovative and so decided that my topic …

Member Avatar for BestJewSinceJC
-2
322
Member Avatar for Norua

I'm having trouble with my lab for a computer class. The problem is as stated: Design a program that generates 100 random numbers, and keeps a count of how many of those random numbers are even and how many are odd. Can someone please help me out with this?

Member Avatar for snippsat
0
141
Member Avatar for P00dle

Hi. First, I'll explain my task: I have 4 text files. 3 of the files contain xml tags and content. The 4th is empty. I need to read the 3 files, and write them to the 4th file. The reason for having 3 files is that the first and the …

Member Avatar for GreenDay2001
0
140
Member Avatar for kisan
Member Avatar for Gribouillis
-1
190
Member Avatar for Kolz

Is there a method that, say, for example... you open a file, and usually the cursor would be at the end right? Is there a function or method that would set the cursor back to the beginning of the file? Thanks!

Member Avatar for vegaseat
0
204
Member Avatar for krishna_sicsr

Hi, Below is my output: FF 0 CMA: 0 IPMI port DE 15E0 TTA: 1 Generic Com port DD 15D0 TTB: 2 Generic Com port DC 15C0 SEA: 3 ACPI System Event FF 0 1 MFPCI DB 15B0 DQA: 2 CMD 649 IDE/ATA Controller DA 15A0 EIA: 3 Intel 82557 …

Member Avatar for stephendoyle75
0
162
Member Avatar for P00dle

Hi, I need to read input from 2 different files, take text from both, combine it, then print it to a third file. That part is easy. What I have a problem with is that some of the text I read in have special characters that need to be escaped. …

Member Avatar for P00dle
0
131
Member Avatar for frank_albers123

I need to write a program that uses the following function [CODE]def pascnext( L ): currentrow = [] if len( L ) == 0: return [1] if len( L ) == 1 and L[ 0 ] == 1: return [ 1, 1 ] else: currentrow += [ 1 ] for …

Member Avatar for jice
0
109
Member Avatar for P00dle

Hi I am ery new to Python. I've only started using it yesterday. Please keep that in mind, as the error might seem simple to you, but I can't understand it. I am trying to run the following piece of code: [code] import re foo = open("PREFIX.txt", "r+") text = …

0
72
Member Avatar for saikeraku

Hi I'm trying to write some functions. This first function is suppose to help shuffle two strings which are the same length into the correct word. So the output would be something like: After shuffling the first string som and the second string trs the word is storms. Here is …

Member Avatar for katharnakh
0
109
Member Avatar for ihatehippies

Here's my problem. I wx application that works great until I close it (leaving the idle editing session open) and then restart it. Then parts of the program see variables that should be things like 'wx.panel' as PyDeadObj .... Once I restart the idle session and re-run the program it …

Member Avatar for ihatehippies
0
138
Member Avatar for pyprog

If I have a file that has a content of this kind: a,b c,d e,f g,h I need to make a list of the letters in the first column, i.e., [a, c, e, g]. I wrote some code which prints these letters but I don't know how to put them …

Member Avatar for snippsat
0
312
Member Avatar for frank_albers123

I am writing a program in python where in the function I input a row in Pascals triangle and the function returns the NEXT row in the triangle. Below is what I have so far and am getting really frustrate...I'm new at this and bad at iterating things. Can you …

Member Avatar for masterofpuppets
0
309
Member Avatar for FengG

Python beginner try to learn pygame. Here is a program I made for random color circles popping out. [CODE]import pygame, random pygame.init() X = 680 Y = 460 def main(): screen = pygame.display.set_mode((X,Y)) pygame.display.set_caption('circles') background = pygame.Surface(screen.get_size()) background = background.convert() background.fill(pygame.color.Color('white')) run = True clock = pygame.time.Clock() while run: clock.tick(30) …

Member Avatar for FengG
0
136
Member Avatar for sneek

Hi, I have a problem because I did not realy get yet when do Py_INCREF or to Py_DECREF. I build a class type that covers a PyObject*-Array. Now I wrote a function like that: [CODE] static PyObject * get_first(MyObject *self) { PyObject *res = NULL; if (!self->size) return NULL; res …

Member Avatar for sneek
0
943
Member Avatar for SMIFMD

Can anybody help me out on creating the ceasar cipher. I am attempting to create the program with several functions, including a function for a password. I think that it adds a few more "bells and whistles" by adding this feature. When I run the script below, what is being …

Member Avatar for masterofpuppets
0
195
Member Avatar for zyrus001

I'm reading in a file and sending the data (once encrypted) to a dictionary, with a hash of the data before and after encryption. I then pickle the dictionary but find the file size is massive compared to the source file size. If I write the encrypted data straight to …

Member Avatar for vegaseat
0
279
Member Avatar for wrobl1rt

I am trying to remove a specific substring from a string... Here are the doctests. I'm just absolutely stumped. Can someone point me in the right direction on where to start? def remove(sub, s): """ >>> remove('an', 'banana') 'bana' >>> remove('cyc', 'bicycle') 'bile' >>> remove('iss', 'Mississippi') 'Mippi' """ def remove_all(sub, …

Member Avatar for vegaseat
0
6K
Member Avatar for krishna_sicsr

f = \ ''' Product: DECNET Node: ALETHA Address(es): 1.1 Product: TCP/IP Node: aletha.ind.hp.com Address(es): 15.146.239.174 ''' lines = f.split('\n') i = 1 ###### To get the IP Address(es) adapter_config = True for line in lines: if adapter_config: # print line import re if (re.match("^Product:\s+",line)): line1=re.split("\s+",line) print line1[5] I want …

Member Avatar for masterofpuppets
0
134
Member Avatar for topcat712

Could someone lend me their brain? :D I thought I had most of it done, until I got an error saying that my 'calcAverage' definition was not defined.. x.x here is the prompt for the program: Write a program that asks the user how many pumpkin weights they have, and …

Member Avatar for masterofpuppets
0
163
Member Avatar for vnproduktionz

[code]# Reading the .csv file energyFile = open("EnergySources.csv","r") stateDict = {} for line in energyFile: line = line.strip() fields = line.split(",") if fields[0] == "State" or fields[0] == "": continue state = fields[0] total = fields[-1] float(''.join(total)) coal = fields[1] float(''.join(coal)) naturalgas = fields[2] float(''.join(naturalgas)) petroleum = fields[3] float(''.join(petroleum)) nuclear …

Member Avatar for vnproduktionz
0
124
Member Avatar for Kezoor

Hello, I begin in Python, and I have the following problem: I retrieve an excerpt of a HTML webpage from the web, and then want the result to be hold in a variable (before being processed by a reg-exp). The function do get the HTML source, but when I assign …

Member Avatar for Kezoor
0
330

The End.