15,406 Topics

Member Avatar for
Member Avatar for coco08

Hi people. I'm trying to create a tictactoe program in python but i'm having some troubles. It's the player against the computer. Now the computer should go on random but still block/win if possible. Right now i'm kinda stuck so feel free to help. I'd prefer it as simple as …

Member Avatar for dekalbxxx
0
556
Member Avatar for novice20

[B]hi all, can anyone tell me how to open a folder on a remote machine connected on same LAN. I need to open a folder in the form "\\remote_machine\folder1\folder2\folder3"[/B]

Member Avatar for novice20
0
3K
Member Avatar for jrp370

ok so i really dont understand this whole recursive stuff and i need some help on a simple program. the problem is to write and test a recursive function max to find the largest number in a list. here is a non recursive function that ive made, [code] def Max(li): …

Member Avatar for Gribouillis
0
2K
Member Avatar for Safia Abdalla

I am working on this program in Python that would allow me to scan for a certain phrase in a certain text document. I used the finditer function in Python's re library.The certain line of code resembled the following: [CODE]phrase=regex.finditer(page)[/CODE] I also had a print statement at the end that …

Member Avatar for griswolf
0
12K
Member Avatar for acrocephalus

Hello! I'm just beginning to learn Python and I would like you to recommend me any good tutorial. I have started with the [URL="http://www.pythonlearn.com/"]http://www.pythonlearn.com/[/URL] and the [URL="http://hetland.org/writing/instant-python.html"]http://hetland.org/writing/instant-python.html[/URL]. I have found them very useful and I would like to continue learning. Furthermore, I would also like to start learning on programming …

Member Avatar for Dylan Solarsh
0
239
Member Avatar for hisan

Hi, i have created python exe file of my code using py2exe module. i need to add my own customized icon for this exe file how to achive this

Member Avatar for slate
0
103
Member Avatar for coril

I'm trying to figure out how to set up a grid using a list of lists. I want the input to be x where the program will then setup a list of x lists, each containing x entries, in this case "0"s.

Member Avatar for Gribouillis
0
265
Member Avatar for furret

Ok, so i've got one definition on my python code, that defines how to find the position of something in an array, then returns the list of all the places that those things are. Then I've got another definition to find the accurate centroid of a position. How do I …

Member Avatar for Gribouillis
0
137
Member Avatar for nosehat

I am working on a project where I need to parse a bunch of user text that comes in different fields. The problem is that the user input doesn't always come in on the same fields. One user might have a name in field 3 and a date in field …

Member Avatar for richieking
0
131
Member Avatar for newbieha

try to get the current cursor position without removing the node [CODE]class List(object): ___slot___=('cursor', 'size') def __init__(self): self.cursor=EmptyCircleNode() self.size=0 def __str__(self): result = "<" node = self.cursor count = self.size while count != 0: result = result + str(node.data) if count != 1: result = result + ", " node …

Member Avatar for TrustyTony
-1
114
Member Avatar for rx21825

I am new to python programming and struggling with a problem I would like help with. I have multiple text files that I would like to join using the first column in each file to serve as the key to align the files. Each file could be several hundred lines …

Member Avatar for TrustyTony
0
2K
Member Avatar for corrwee

Hey guys I'm having some trouble with a homework question from Zelles python. I have to make a Set class then test a variety of methods. However my teacher wants us to just use lists and not actually sets. I'm getting an error for the setElements method, it keeps saying …

Member Avatar for SgtMe
0
248
Member Avatar for killerpopiller

Problem with storing extracted values in SQLite - How to adress or index list of values for proper insertion into table. The Regex works fine: input logging data looks like: 0.0.0(06026104) 1.6.1(0.1501)(1011111000) 1.6.1*32(0.1446)(1010190800) 1.8.1(02484.825) 1.8.1*32(02449.574) correct regex output: 06026104 0.1501 02484.796 [CODE] with open("usage.log") as fp: for line in fp: …

Member Avatar for killerpopiller
0
244
Member Avatar for johanngomes

(Python begginner, please be gently) Hi, i'm having some troubles with turning one python project i made into an executable, using py2exe (via GUI2EXE). The program is compilling well, it generates the executable, but when i try to execute it, i get the following error: ImportError: No module named twitter …

0
41
Member Avatar for coril

So far, I have: [CODE]def printSquare(x,y): for z in range(0,x): print(x*y)[/CODE] printSquare(3,'%') prints out something like this: %%% %%% %%% instead of using the '*' operation, is there a way to print x numbers of y separated by commas (for better spacing) ie: print(y,y,y)?

Member Avatar for Gribouillis
0
574
Member Avatar for hisan

Hi, I want to know how to use Python variables in My sql statement and below is the syntax i am using import MySQLdb name="XYZ" number="123456" db=MySQLdb.Connect("localhost","root","12345","phone") cursor=db.cursor() sql= ("""INSERT INTO phonebook(number, Mobile) VALUES(%s,%s)""" , name,number) cursor.execute(sql) db.commit() db.close() but this throws the error please refer the attached screen shot …

Member Avatar for hisan
0
6K
Member Avatar for PhEnSciLaBu
Member Avatar for keltik

Hi there, at university i have to program OO-style in Python. What i got now is a "Point"-class and a "Triangle"-class. The "Triangle"-class has a method [ICODE]a()[/ICODE] that needs to return the length of the AB-edge, but it doesn't instead it concatenates the Point.__str__() methods return values together, which is …

Member Avatar for TrustyTony
0
153
Member Avatar for dmurder

it keeps looping over and over again no matter what i put in [CODE]def getScores(totalScores, number): score = input('Enter their score: ') while score <=0 or score >=100: print'You must enter a number between 0 and 100' score = input('Enter a number between 0 and 100:') for counter in range(0, …

Member Avatar for richieking
0
150
Member Avatar for dmurder

i get this error when i get to a certain part in the program Traceback (most recent call last): File "C:/Users/Family/Desktop/13.py", line 54, in <module> main() File "C:/Users/Family/Desktop/13.py", line 10, in main averageScores = getAverage(totalScores, averageScores, number) File "C:/Users/Family/Desktop/13.py", line 46, in getAverage averageScores = totalScores / number TypeError: unsupported …

Member Avatar for richieking
0
130
Member Avatar for novice20

hi all, can anyone tell me hoe to open a file from one machine, when the file is present on a remote machine, specifying it's IP address?

Member Avatar for richieking
0
640
Member Avatar for banannamoofin

I am struggling with one part of my specification to complete my program :/, currently it does let me enter different items into containers and creates new containers as they are needed. However now I need the program to handle how it packs the items differently. Before when numbers such …

0
95
Member Avatar for SomeKittens

I'm trying to convert text to a variable name. So far, I've been able to solve most things with Google, but this is really frustrating: Error: Traceback (most recent call last): File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 33, in <module> main() File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 21, in main while not …

Member Avatar for Gribouillis
0
272
Member Avatar for Swedenrock

Hi! I've created three list in a class but when I print them i get <__main__.Kort instance at 0x16eb22b0> Anyone know how I can get the list to print put its "real" elements? [CODE] class Kortlek(): def __init__(self,colors=["blue ", "yellow ", "red "], forms=["triangel", "circle ", "square "], numbers=[1, 2, …

Member Avatar for TrustyTony
0
121
Member Avatar for dmurder

i have an introduction to programming class and i'm trying to write this program and the program is supposed to loop if you don't input a number within a specific range but it doesnt do it [CODE]def main(): endProgram = 'no' print while endProgram == 'no': totalScores = 0 averageScores …

Member Avatar for TrustyTony
0
88
Member Avatar for wazaa

My problem is that i have to create a program to hold a series of weights in containers (elements in a list). The max weight for each container is 20units. I have got this working as this: containers = [0] inp = input("Enter a weight, 20 or less, or enter …

Member Avatar for wazaa
0
134
Member Avatar for Swedenrock

Hi! I'm working on a solitaire game, with a different card deck. First I create a big list with 81 elements (cards in this case), cardList. From this list, six cards are ramdomly picked and put into another list, playerCardList, and printed on the court. Once the cards are printed …

Member Avatar for woooee
0
143
Member Avatar for furret

Hey, I've got an array full of random numbers and I want to say if the array is below a certain value, say 15, then to make everything in that array that less than 15 equal to zero. So far I've tried a few things and they've not worked, and …

Member Avatar for woooee
0
102
Member Avatar for 1989sam

I have these 3 string: YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs YELLOW,SMALL,STRETCH,ADULT,Tdsfs YELLOW,SMALL,STRETCH,ADULT,TD I would like to remove everything after the last "," including the comma. So i want to remove these parts ",T21fdsfdsfs" ",Tdsfs" and "TD". How could i do that in Python?

Member Avatar for seanbp
0
107
Member Avatar for xtra333

Hi people. I am having trouble printing out a list of items with n items per line. Here is my current code. [CODE]def printList(lst, lineCount): # given a list of items, print it out in # lineCount items per line. count=0 strList= '[ ' for element in lst: strList = …

Member Avatar for richieking
0
149
Member Avatar for Banjoplucker

Please look at my code at: [url]http://www.bpaste.net/show/11961/[/url] I appear to have gone down a "blind alley" here. Having identified the location of the Word perfect headers, I need to verify that they are indeed genuine by reading the hex value 10 bytes from the beginning of the header. If it …

Member Avatar for richieking
0
121
Member Avatar for Gribouillis

This snippet generates the best rational approximations of a floating point number, using the method of continued fractions (tested with python 2.6 and 3.1).

Member Avatar for Gribouillis
1
1K
Member Avatar for twohot

This issue is probably discussed before. However, I can still use a little insight. I am a python beginner looking to develop a small client/server suite. The clients will reside in different PCs across a LAN and their job is to recieve a file (say, a .txt file) from the …

Member Avatar for woooee
0
117
Member Avatar for hbluthi

I'm making a Card class and need to make sure that the suit is valid. When I call on the Card class and construct one setting the suit to 'Jordan' it actually ok's that suit and prints 'Ace of Jordan'. Instead it should become the default, of Spades. What am …

Member Avatar for hbluthi
0
660
Member Avatar for Oldguy1

Hey I'm very new to the programming world, and what i am trying to do is produce a Koch Snowflake via turtle from python2.5. this is what I have so far... [CODE] from turtle import * def snowflake(lengthSide, levels): if levels == 0: return forward(lengthSide), right(120), forward(lengthSide), right(120), forward(lengthSide) forward(lengthSide) …

Member Avatar for ohernandezmit
0
3K
Member Avatar for robm612

Ok guys so i am trying to create 2 versions of a program which sorts items into boxes. The first version i have to create puts the item weights (integer between 1 and 20) into the first "box" they will fit into. So given the input 11,17,3,5,4 the list the …

Member Avatar for TrustyTony
0
147
Member Avatar for tk-421

Monday morning, our final exam is to write a Python program according to whatever the teacher will throw at us. Any ideas as to how or WHAT to study to be ready for anything? (Most of the class expects to fail this, btw. I don't want to be among those …

Member Avatar for Gribouillis
0
97
Member Avatar for Naynah

I have to create all the method signatures in the ResizableArrayList and then fill it in with comments. And each method is supposed to be blank with a return null or --1. How do i do this?

Member Avatar for richieking
0
108
Member Avatar for jozz3

I am working on a program with classes and a main function. This game involves tanks moving around a grid of defined size, and shooting at each other. Each tank has a name, armour and firepower. On the grid, there are randomly generated squares that contain extra armour or firepower. …

Member Avatar for taskkiller
0
126
Member Avatar for polanski

Hey everyone, new here. I'm looking for a little help with my program. Its supposed to take a txt file called test.txt, and removes all spaces trailing at the end of lines. ex. (note the spaces) "python " -> "python" "daniweb is great" -> "daniweb is great" " forum" -> …

Member Avatar for richieking
0
161
Member Avatar for convoluted

Hope you kind folk can spare a bit of advice. I'm trying to find a clever way to modifying a part of an image without replacing the image completely. For instance, let's say I have an image of a car and I would like to show the tire is flat. …

Member Avatar for richieking
0
176
Member Avatar for Hawkeye Python

Hello :) I'm from Brazil, so sorry about my english. This is the first code I post here - I'm a begginer in Python. It is a function to calculate determinants of matrices. You can attach it to a class if you wish. Please leave a comment if you wish …

Member Avatar for Gribouillis
0
3K
Member Avatar for Naynah

I'm a Python semi-beginner and i have to do a prac but the problem is i've totally forgetten how to do it! Can you please help me get started with part 1 even if its just 1.a because every time i tried to get it to work it keeps saying …

Member Avatar for Naynah
0
165
Member Avatar for HoneyBadger

Guys, how do I add an item to a list using a loop? My loop in a nutshell does this: [CODE]for w in book_line.split(" "): word_list = [] if w != "": word_list.append(w.lower()) return word_list[/CODE] While experimenting with this I got mainly two results: 1.) When I use return word_list, …

Member Avatar for HoneyBadger
0
3K
Member Avatar for KMC

Hello, I am completely stuck on a question I was assigned and was hoping for a little guidance to get me started. The question is: Create a program that outputs the molar mass of a molecule. The user will enter a molecule with each atom individually (CO2 would be entered …

Member Avatar for KMC
0
80
Member Avatar for patrickgormally

Hi! I am trying to do a project in which I draw a Christmas tree with about 3 segments, filled in with color and with writing below it saying "Merry Christmas". Sadly, I have no idea where to being! I'm able to draw the Christmas trees using stars by defining …

Member Avatar for woooee
0
3K
Member Avatar for xtra333

Hello. My instructor want me to write a magic Square code. And here is what the square is supposed to print: 11 18 25 2 9 10 12 19 21 3 4 6 13 20 22 23 5 7 14 16 17 24 1 8 15 Here is my current …

Member Avatar for woooee
0
125
Member Avatar for patrickgormally

I am reading a text file inside Python that contains salaries and the raise they will receive as a percent. I am trying to multiply the initial salary by the percent and print the salary after the raise has been applied. I keep receiving an error message which is as …

Member Avatar for patrickgormally
0
3K
Member Avatar for longlongsilver

i have my code and i want to cycle through the following colors blue green orange red yellow. i got blue but i dont know how to the rest [CODE]from Tkinter import * myfont = ("Arial", 1, "bold") window = Tk() window.title("grid") window.geometry("500x420") frame = Frame(window) frame.grid() button0 = Button(frame, …

Member Avatar for richieking
0
310
Member Avatar for HoneyBadger

Guys I have a text file, and I am trying to get my program to focus on a specific part of the text. How would I do that? I tried this to no avail: [CODE]f = open("book.txt") f.readlies()[10:3340][/CODE]

Member Avatar for TrustyTony
0
110

The End.