15,406 Topics

Member Avatar for
Member Avatar for newbieha

def sort(l, x) if len(l) <= 1: ### if my list is smaller than 1, simply return l return l else: ### Here is the problem i don't know how to solve - how to find smallest element within a list using recursion? I've tried to call another function in …

Member Avatar for TrustyTony
0
2K
Member Avatar for ch1zra

can I somehow extract single file from a zip archive without replicating directory structure inside zip file ? for example file I need is : archive.zip/folder1/folder2/fileIneed.doc when I use zipfile.extract I get the file, but I get it in destination folder with same directory structure. I'm at home now and …

Member Avatar for Gribouillis
0
144
Member Avatar for danholding

hey guys n girls, im using python 3.1.2 i am currently creating a process to: 1) check a directory does not exist, 2) check for illegal char's from a list i have made, 3) pass it to a program,-program creates directory, 4) and passes a value back to python 5) …

Member Avatar for Gribouillis
0
269
Member Avatar for lewashby

I'M getting an error in the following program on line 38 to a function call. The function is in the gameobjects module and the there's an error there as well on line 21. Here's the code. Code:[CODE] background_image_filename = 'sushiplate.jpg' sprite_image_filename = 'fugu.png' import pygame from pygame.locals import * from …

Member Avatar for Gribouillis
0
192
Member Avatar for mikeyj9009

I really need help. The output is supposed to read a text file with the coordinates and print them to a text file, but I am not sure what lines of code to write and where to insert them. Here are the coordinates that are in there own text file: …

Member Avatar for woooee
0
102
Member Avatar for mtmalleus

Hey guys. I'm new to Python. I kinda blundered into a CIS major at the university I attend, and I have to say, I haven't enjoyed the Python class so far. It's so... esoteric. I'm having a TON of trouble grasping what the rest of my class view as simple …

Member Avatar for Schol-R-LEA
0
185
Member Avatar for lewashby

[CODE]import pygame from pygame.locals import * from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) font = pygame.font.SysFont('arial', 32) font_height = font.get_linesize() while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.fill((255, 255, 255)) pressed_key_text = [] pressed_keys = pygame.key.get_pressed() y = font_height for key_constant, pressed …

Member Avatar for woooee
0
6K
Member Avatar for iwanttolearnc

the problem is that of a path planning algorithm. the obstacles will be rectangular shaped boxes. what i need to do is detect the rectangular boxes, and then add a black "aura" around these boxes. any ideas on how i go about doing this?

Member Avatar for woooee
0
99
Member Avatar for haojam

Dear Sir, I would like to extract only unique terms from all sdrf.txt files but this python code outputs unique terms for every file individually. Like Array Data File , Array Design REF ... are repeated in most of sdrf.txt files so i don't wanna print it as unique terms. …

Member Avatar for woooee
0
249
Member Avatar for me4ka86

Hello Everyone, i would like to make a file in which i move the mouse to coordinates x and y and click the scroll button(middle button). this is what i want but works for left and right i have on idea how to make it work with scroll/medium button. any …

Member Avatar for Gribouillis
0
106
Member Avatar for ZigZagMan

Hi guys, new here, and new to python. And I thought I would ask for a bit of guidance on this piece of code I'm working on. The following block of code is supposed to output all positive factors of the entered integer. However, it does not work properly. The …

Member Avatar for TrustyTony
0
75
Member Avatar for kimmi_baby

Hi, I have created a program in Python which creates a database called inb104 and loads the data from text files into the mySQL server. The code works perfectly fine. The data is inserted into the table without any issues. The problem is that I would like to place the …

Member Avatar for Gribouillis
0
600
Member Avatar for Don Brooklyn

Hi there, I would need some help with my code...its in python, and the thing I have to do is to make points of the matrix of the object be displayed in a way to make the first camera position as a start of the coordinate system! to clarify a …

Member Avatar for TrustyTony
0
112
Member Avatar for sravi.pearl

Hai all... I want to get different colored bars for labels 'Bill', 'Fred', 'Mary', 'Sue' can any one please tell me ...as soon as possible..... [CODE]#!/usr/bin/env python """ The new ticker code was designed to explicity support user customized ticking. The documentation http://matplotlib.sourceforge.net/matplotlib.ticker.html details this process. That code defines a …

Member Avatar for TrustyTony
0
170
Member Avatar for tomtomisaballer

This is my code: Vigenere cipher : [CODE]from graphics import * ##def encode(message, keyword): def main(): win= GraphWin("Vigenere cipher", 400,350) messagebox = Text(Point(100, 60), "Enter message to encode") keywordbox = Text(Point(63, 120), "Enter Keyword") encodedbox = Text(Point(75, 250), "Encoded Message") message = Entry(Point(290, 60), 20) message.setText("") keyword = Entry(Point(290, 120), …

0
60
Member Avatar for hbluthi

Hi guys. This is my first post here and I've read through the forum quite a bit and can't wait to get more involved. So here is my main problem: getting my code to take the text I enter into an entry box to be recognized as a string so …

Member Avatar for hbluthi
0
116
Member Avatar for barney1

Hello I'm trying to make a stem and leaf plot. The first function is supposed to call the other two functions and return the final plot. My code works for the first elemnt in the list and then stops. Is there something I have to do within my for loop? …

Member Avatar for TrustyTony
0
546
Member Avatar for rahul8590

i have a csv file from where in i read the data and store individual coloumns in list , but for the last coloumn i am getting \n in the list . i want to get rid of that . [CODE] f = open('datagen.txt') for lines in f: line = …

Member Avatar for TrustyTony
0
202
Member Avatar for OffbeatPatriot

I made a wxPython gui to interact with a camera, however the lab is very matlab centric and the professor wants everything to be controllable from matlab. I think this is more of a matlab problem, but it's python related and I thought it might be a little odd to …

Member Avatar for uve
0
796
Member Avatar for kevintse

Hi, all I have been learning the python language for a couple of weeks. For now I only know a little of the language, the syntax, usage of the builtin types such as str, lists, dicts, and tuples, this is fine for writing some simple scripts to process text files. …

Member Avatar for kevintse
0
151
Member Avatar for _neo_

Hi all. I'm trying install python 3.1.2 on RHEL4 from source, but 'make' failed to build some necessary modules. Followings are from build log: *** WARNING: importing extension "_ctypes" failed with <class 'AttributeError'>: 'module' object has no attribute 'load_dynamic' Python build finished, but the necessary bits to build these modules …

Member Avatar for _neo_
0
759
Member Avatar for thekevinguy

Hello, I'm pretty new to programming in general, and I'm trying to get started with python. Whenever I open up IDLE, everything seems to work fine. However, when I go to File>New Window, I just get a blank window and everything freezes up. If I restart my computer, I can …

Member Avatar for Gribouillis
0
155
Member Avatar for DocBreen

[CODE] b2 = raw_input("Select your action:") if b2 == "Attack": mgeHP = 2500 print "You have decided to attack the mage." while True: dmg = random.randrange(1, 125, 1) mgeHPN = mgeHP-dmg print "You did" , dmg , "damge to the mage, giving it" , mgeHPN , "left" mgeHP = mgeHPN …

Member Avatar for cghtkh
0
163
Member Avatar for Bombshock

Hey Daniweb, I'm starting out learning python and have been looking around and saw the thread on printing a line that starts with a specific word, I would like to create something similar except take numbers out of text and print them so I can graph them. So far I've …

Member Avatar for TrustyTony
0
149
Member Avatar for Syphilis

Ahoy Sailors! So to simplify this right from the start, When someone connects to my Host script, They first send a string with their PC name attached. [code]n:JoeyBlowHole-PC[/code]We'll store this into a variable, Along with any others that are being sent. So it may look like this. [code]JoeyBlowHole-PC:JohnBinBag-PC[/code]Now I'm needing …

0
67
Member Avatar for darma001

Dear friends, I am a new programmer and i have a task to make a phonebook with python. Please help me to finish my task. The program should repeatedly ask the user for input. Each primary input is one of the words “help”, “lookup”, “enter”, “remove”, and “quit”. If the …

Member Avatar for ultimatebuster
0
2K
Member Avatar for evertron

This is my first function in python and i need to get item quantity and price loops into the function Processorderitems. I took out the items loop because I was not doing anything with it. I need to return the subtotal and I have a 3% discount for quantities over …

Member Avatar for woooee
0
88
Member Avatar for matkod

hi, I'm creating a game with pygame and i want to create a matrix that will represent the map(where each tile will be). my pygame code is ok, because if i create the map without loading the tilemap (the matrix file) the game runs ok. that would be good but …

Member Avatar for Gribouillis
0
185
Member Avatar for novice20

Is there any method or library to translate pysnmp OIDs to human readable strings??

0
61
Member Avatar for DocBreen

Here's the code I need to loop: [CODE] dmg = random.randrange(1, 10, 1) print "You have decided to attack the giant rat." ratHP = 100 ratHPN = ratHP-dmg print "you did" , dmg , "damge to the rat, giving it" , ratHPN , "left" ratHP = ratHPN [/CODE] If you …

Member Avatar for Gribouillis
0
119
Member Avatar for nor_fairuz

Hi all, I would like to ask. Im Fairuz and the new member for this forum. I having problems to sort the multi dimentional array in python. ie: [('DcaUiVb_B09398-11', [None]), ('m3sui_R66441-35', []), ('m3sui_r26557-01', []), ('m3sui_R31225-24', []), ('m3sui_r66147-03', []), ('m3sui_R31225-23', []), ('m3sui_R30803-10', [])] I have the list but im having problems …

Member Avatar for Gribouillis
0
189
Member Avatar for Fallen05

Hi.. Ive been doing python for about 2 days now (my 1st programming language) and im wondering, after ive made the .py file, and all the codes in it, how do i run it? To be honest im not even sure if the term compiling is right... I am doing …

Member Avatar for Fredo699
0
283
Member Avatar for KrazyKitsune

This might be a little challenging, but I'd like to know. [code=syntax]from math import sqrt y = int(raw_input("> ")) x = sqrt(y) print x [/code] In this code, say I input 4 for y. The output will be 2, naturally. However, say I have 2 for y. I'd get something …

Member Avatar for KrazyKitsune
0
168
Member Avatar for Reverend Jim

In the book, wxPython in Action (page 65), the following code shows how to bind an event to a frame (self) and to a button. In the case of the frame event (wx.EVT_CLOSE), no source argument is specified because the event is being bound to the object refenced as "self". …

0
77
Member Avatar for evertron

The user enters a number and the program should output that amount of rows and colunmns. I have tried a couple of different ways butcant quite get it even though I think I am close. for example if 10 is entered it should look something like this: O OO OOO …

Member Avatar for evertron
0
237
Member Avatar for jingo1126

im currently running on windows 7 and i cant seem to find some suitable installation of mysql for python 3.1.2.. any help on this?my professor havent gave me any links on where to download it, anyone would mind helping me on this? or as i tried import mysqldb and i …

Member Avatar for Reverend Jim
0
110
Member Avatar for Roelof Wobben

Hello, I have this code : import urllib import zipfile import re totaal = 0 commentaar = [] lus = True image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/channel.zip","channel.zip" ) bestand = "readme.txt" zf = zipfile.ZipFile('channel.zip') while lus == True : for filename in [ bestand ]: try: data = zf.read(filename) except KeyError: print …

Member Avatar for Reverend Jim
0
125
Member Avatar for Thropian

I've been doing programming in tkinter for awhile now and I came across a problem...this problem only shows up after a single part but here is the code...kinda lengthy.if you go to the equip menu and equip bare neck you can't change necklaces again. any help in shortening this or …

Member Avatar for Thropian
0
4K
Member Avatar for tpkemme

so now that i have gotten farther in the code, it prints the substrings correctly, but i can't get the program to stop correctly. basically, i'm looking for the longest common substring. def main(): input1 =raw_input('Enter string: ') input2 = raw_input('Enter second string: ') if input1 > input2: str = …

Member Avatar for TrustyTony
0
152
Member Avatar for otherdummy

Hi, I have just started my first semester in a Bachelor program 'Computer Engineering'. I have above basic knovledge in Java SE and currently am interested in Python. The problem is that I'm facing some difficulties in determing my purposes about my future career in IT field. I used to …

Member Avatar for etftw
0
249
Member Avatar for ddalgibbang

Hello Please excuse my lack of knowledge to python, but I just cannot understand how time complexity works. I've read many threads on this forum regarding time complexity but I am still quite confused. Our prof has given us this example: [CODE]def foo(n): ! while (n > 0): ! ! …

Member Avatar for Gribouillis
0
115
Member Avatar for tpkemme

I have a pretty simple coding function that returns all possible substrings of a string including the string itself def main(): str = raw_input ("Enter first string: ") size = len(str) for sub_len in range (1, size + 1): for idx in range (0, size - sub_len + 1): sub_str …

Member Avatar for TrustyTony
0
137
Member Avatar for ganeshredcobra

am using debian lenny and tried to create a shutdwon script using python import os os.system("sudo shutdown -h now") i cant use this in debian lenny then how will i implement

Member Avatar for Gribouillis
0
2K
Member Avatar for techie1991

Can someone please direct me to the code for the class <int> in python. I know that it must have written in C, but I could not understand, where to ask this query. Though I tried to figure it out myself, but could not even understand, which folder to attack …

Member Avatar for techie1991
0
156
Member Avatar for Roadphantom13

Hello everyone. This is my first post so if something doesn't work, bear with me. I'm a beginner at python and tried to write a program that will calculate Average Word Length. I wrote what I thought should work but the final answer keeps coming out to an average of …

Member Avatar for forsakenedzero
0
5K
Member Avatar for Roelof Wobben

Hello, I have a image with a grey band in it. How can I know the values of only the grey band of the image ? Roelof

0
68
Member Avatar for dustbunny000

So I have this list of strings. They all of the strings have a 18 capital letters. I want to assign each letter a value and them sum up the total score. [CODE]window=['SALHWRAAGAATVLLVIVL', 'ALHWRAAGAATVLLVIVLL', 'LHWRAAGAATVLLVIVLLA', 'HWRAAGAATVLLVIVLLAG', 'WRAAGAATVLLVIVLLAGS', 'RAAGAATVLLVIVLLAGSY', 'AAGAATVLLVIVLLAGSYL', 'AGAATVLLVIVLLAGSYLA', 'GAATVLLVIVLLAGSYLAV', 'AATVLLVIVLLAGSYLAVL', 'ATVLLVIVLLAGSYLAVLA', 'TVLLVIVLLAGSYLAVLAE', 'VLLVIVLLAGSYLAVLAER', 'LLVIVLLAGSYLAVLAERG', 'LVIVLLAGSYLAVLAERGA', 'VIVLLAGSYLAVLAERGAP', 'IVLLAGSYLAVLAERGAPG', 'VLLAGSYLAVLAERGAPGA', …

Member Avatar for slate
0
183
Member Avatar for Overachievious

Hey, I am working on a program for my class where we are supposed to count the letters that occur in a given string, with decreasing frequency. For instance, it would say there are 150 A's, 234 B's, 25 C's, etc. Plus, it would then become possible to sort the …

Member Avatar for TrustyTony
0
226
Member Avatar for Shadow-Illusion

I am trying to insert data from a text file into an SQL table. I'm getting this error: " csv_data = csv.reader(file('TxtFile1.txt', 'r')) TypeError: 'list' object is not callable " [code] import MySQLdb, csv, sys conn = MySQLdb.connect (host = "localhost",user = "a", passwd = "b",db = "c") c = …

Member Avatar for djmagba
0
3K
Member Avatar for G_S

Hello, Now I'm making a program for creating language glossaries, but the problem is that windows uses ANSI for encoding text files, and the program that will read these files (which is not mine) only displays words in utf-8 encoding. Since my program is multiplatform, it can also work under …

Member Avatar for woooee
0
7K

The End.