15,192 Topics
![]() | |
hi, i have to make a simple sudoku solver, i am done 3/4 of it but i'm having a little trouble on somethings, here is what i've got so far [CODE] import copy def display(A): if A: for i in range(9): for j in range(9): if type(A[i][j]) == type([]): print … | |
I need to be able to print at an offset where the second element of the second list matches up with the first element of the first list. For example have a's line up with the b's: [CODE] list = [[a, b, c, d],[a, X, X, b, c, d],[a, X, … | |
I need the function to display a square of numbers. This is the actual function. [code] def draw(n): for i in range(n+1): print i*(n) [/code] but if i call the function [code] def drawBlock(3): [/code] then the output should be 333 222 111 but i cant understand how to get … | |
![]() | hi everyone, I am trying to design an assembler program with Python using Tkinter and so far it is going pretty good. I just have one question: Is there anyway to change the text color of just a selected text using a text area? What I mean is, you know … ![]() |
I'm trying to print horizontally not having any luck. I need to print I#x where x one through the length of a list i.e.-I#1 I#2 I#3 I#4 etc. This is what I have which is syntactically wrong: [CODE]for x in range(1, len(depend)): print "%05s" ('I#'+str(x))[/CODE] Could someone please point me … | |
How do I get my python code to compile one line at a time so I can see exactly how the code works. If anyone knows how to do this with Wing IDE that would also be helpful. Thanks. | |
Does anyone use Python on a Windows7 machine? What is your experience? Does it work well? I am thinking about getting a new computer and also start some Python programming. | |
I am just starting with python and I am trying to write a program that interfaces with flickr. I am using the interface flickr.py found at the following link: [url]http://code.google.com/p/flickrpy/[/url] I am calling the following function: [CODE]myPhotos = myPhotoSets[0].getPhotos()[/CODE] The shell is telling me there is an error in this … | |
SO I want to make a basic proxy where I want to modify some of the data coming through. I checked out asyncore but that doesnt allow HTTPS and it is pretty complicated, so I just looked at Twisted. My question is since HTTPS is not supported by Twisted, can … | |
how could i square the result of function?.. so when i call the functioon [code] def sum(first, last): for i in range(first, last+1): print i return i**2 [/code] it gives the answer as 50, as it should square 3,4 and 5=50 ![]() | |
When the function is called count(3,5) then it should display 3,4 and 5.. but my function only seems to show 3 and 4 and not 5? def count(first,last): for i in range(first, last): print i | |
Trying to make a file that tests how many seconds it takes for python to use a while loop to count how many seconds 1000 loops takes. Not working, I don't know why. Every time I run this it outputs "('It took 0,0')"...The while loop didn't start. [CODE]import time import … | |
hi everyone. Say I have my project directorys set up like so: /glider /libs classes.py /graphics /rooms room images go here I'm trying to access a image from graphics/rooms, but from classes.py. I'm using pygame, and I know to go back a folder in a dir; you use: [CODE=python]# go … | |
Hi! I would like to build a minimalistic program which finds the tokens from a text. Its output should ideally be identical to the result of: [CODE]gposttl input_file | awk '{print $1}'[/CODE] which are just the tokens. An example: [CODE]That's a word and this is a number 123.456. I would … | |
![]() | Hello, I'm having trouble making a little parser for the eix program (a gentoo portage search tool) I need to delete (or not write) the last lines of the output (overlays and total packages), they will start always like '[n]' where n is the number of the overlay and the … ![]() |
okay the point of the program is to have the user select two points which would be the points that make up the base of the house, then they select a point inside the house that will serve as the center of a door, however if they click outside of … | |
for example if i wanted to add a list to another list, like: a = [a,b,c] b = [1,2,3] my code: [code] def add(a, b): a = a.append(b) [/code] it would output ['a', 'b', 'c', [1, 2, 3]] what do i have to change to make it output ['a', 'b', … | |
Hi, I read that e.g. PyTupe_SetItem() steals a reference to the given object but I didn't get what that mean to me and why doesn't PyDict_SetItem() do it either? Jonny | |
My connect4 game works fine, but after a user wins the program exits and prints a few tracebacks. Is it possible to not print any tracebacks and just exit a program smoothly? | |
I have some pretty basic questions about the different types of numbers in python (and other languages). What is the difference between an integer and a floating point number? I'd appreciate a detailed answer explaining some of the fundamentals. | |
Hai friends, I have a question which is very fundamental.. After installing boost python and bjam from ubuntu 9.04 repositories i can't find a clear detailed description about compiling and running the boost python program from it's tutorials .. Can any among you please tell me what are the options … | |
I require some help on how to go about writing a function that removes an item from a list along with how to return a list with an item removed. Any help would be gladly appreciated. | |
I've been thinking recently about how cool it would be to make a rpg/text adventure game where you could fight monsters- in my case fallout3 inspired mutant hicks from the game point lookout. I have the room classes. (I can give code later in the day). how would i make … | |
[CODE]import xchat hooker = None __module_name__ = "Away Script" __module_version__ = '1.0' __module_description__ = "States that your away" def away(word, word_eol, userdata): chan = xchat.get_info('channel') xchat.command("msg " + chan + " I'm Away") def toggle(word, word_eol, userdata): global a if word[1] == 'on': xchat.hook_print("Channel Msg Hilight", away) xchat.command("echo Loaded") elif … | |
Hi, Very new to Python and still stumbling around but need some help. As part of a larger script, I'd like to run a routine that checks for the existence of a file once a second for about 3 minutes and if it suddenly appears, carry on with the rest … | |
Hi I have a text file which has the following: 'username=sonia\n', 'password=password' I want to split sonia and place it in a variable called username. I was able to accomplish the following but could not remove the new line characters. text = 'username=sonia\n', 'password=password' text[0].split('=')[1] This returns 'sonia\n' So now … | |
People, please help me! I must write 30 programs on python but not well understand this program. I don't know how to write 4 programs which are simple. [B]1)[/B] The polysemy of a word is the number of senses it has. Using WordNet, we can determine that the noun dog … | |
![]() | This is a split from another thread. I'm trying to think of a good way to simulate action other than just a hit/miss list. I want more complicated results andalso so that the character doesn't always die... Hmmm... okay. So I think I would do it like this: my_str = … |
Here is an example I was thinking of ... [code=python]import random import time def delay(seconds): time.sleep(seconds) def shuffle_hitlists(my_hitlist, mo_hitlist): """shuffle the two lists and return the result""" random.shuffle(my_hitlist) random.shuffle(mo_hitlist) return my_hitlist, mo_hitlist def battle(my_hitlist, mo_hitlist, my_strength, mo_strength): # player starts swinging first for k in range(len(my_hitlist)): my_hit = my_hitlist[k] mo_hit … | |
I have a script for renaming files, but can not seem to iron out the bugs. I am trying to rename a list of files: File1.File1 File2.File2 etc I need them to be renamed to: File1 File2 etc This is the code so far: [code] import os import sys import … |
The End.