14,945 Topics

Member Avatar for
Member Avatar for Matt Tacular

I have a function which should work, and it actually does... just not all the time. Sometimes it just freezes. Can anyone identify a problem in the ai_northAmericaCheck(): function? Here is the code: [php] import random ai_countries = [] firstTurnsCountries = [] northAmericaList = [0,1,2,3,4,5,6,7,8,9] availableCountries = range(20) country0value = …

Member Avatar for woooee
0
81
Member Avatar for mattyd

About one month ago or so my Dr. Python compiler (interpreter) died. I had closed Dr. Python to go and eat dinner then came back to re-open and continued where I had stopped and... nothing. This came at a terrible time as I was in the middle of some very …

Member Avatar for Ene Uran
0
188
Member Avatar for jDSL

Hi, this is my first post, and im trying to compare a matrix to find the minus element greater than zero, my list is matrix= [9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5] I dont want to use "min" function because each element is associated to (X,Y) position. Thanks a lot ! jDSL

Member Avatar for Ene Uran
0
99
Member Avatar for sneekula

I know that one has to be careful with mutable arguments like lists applied to function calls, so that things like this won't accidentally happen: [php]def add_item(list2): list2.append(99) return list2 list1 = [1, 2, 3] list3 = add_item(list1) print list1 # [1, 2, 3, 99] oops! print list3 # [1, …

Member Avatar for jrcagle
0
226
Member Avatar for babutche

Hi, I am trying to average student GPA. I thought I had this problem solved but then I ran it and the GPA did not come out correct. Can anyone give any suggestions? [CODE]import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) …

Member Avatar for babutche
0
1K
Member Avatar for sneekula

I took a mixed type list and set out to find the min and max values. The results are very surprising to me: [php]mixed_list = [11, 'Dick', 12, 'Mary', 7, 'Zoe', 9, 700, 777, 'Paul', 13456789] mn = min(mixed_list) mx = max(mixed_list) print mn, type(mn) # 7 <type 'int'> print …

Member Avatar for vegaseat
0
3K
Member Avatar for sneekula

I was experimenting with the nested list example in thread: [URL]http://www.daniweb.com/techtalkforums/post246791-72.html[/URL] and was trying to search a nested list like that: [code]nested_list = [1 ,'Dick', 2, ['Mary', 7, 9, [700, 777, 'Paul']], 13] if 'Paul' in nested_list: print 'found Paul' else: print 'Paul not found' [/code]It always tells me that …

Member Avatar for vegaseat
0
104
Member Avatar for sneekula

I want to make a Tkinter button respond to a left and right mouse click differently. How can I do this?

Member Avatar for vegaseat
0
8K
Member Avatar for sneekula
Member Avatar for babutche

Hi, I did get the problem fixed with my "break" not working properly but now my ValueError will not work properly. If you enter a number that is not a floating number it should create a value error(as a matter of fact it did before I fixed my other problem …

Member Avatar for babutche
0
139
Member Avatar for babutche

Hi, I am trying to extend my "Student with the best GPA" program so that it allows the user to sort a file of students based on gpa, name, or credits. The program needs to prompt for the input and output files and also the field to sort on (gpa, …

Member Avatar for babutche
0
458
Member Avatar for babutche

I am having a problem getting my "break" to work correctly in this program. Can anyone help me see what I am doing wrong? This is my program: [code]import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) self.qpoints = float(qpoints) def getName(self): …

Member Avatar for babutche
0
111
Member Avatar for sneekula
Member Avatar for sneekula
0
12K
Member Avatar for Matt Tacular

I'm going to have to include a lengthy bit of code, but its every necessary part for you to see what I need. [php]import random availableCountries = range(20) # <--- Used at games start, player's countries taken from here firstTurnsCountries = [] # <--- Player one's country possesion secondTurnsCountries = …

Member Avatar for Matt Tacular
0
117
Member Avatar for chris99

My program won't read the listbox correctly. The output from the print statements are as follows: [QUOTE]Dronfield Sheffield 2.20 ('1',)[/QUOTE] I want the list item "B-line" to = 1, but due to the wierdness of the value, it reads it as ('1',) It is meant to read from the passinfo.txt …

Member Avatar for chris99
0
1K
Member Avatar for mattyd

My current GUI program, in part, will display a button which the user may choose to press (or not, in some cases): [code] btn1 = Button(root ,bg="Black", text="HIT", image=image01,command=show_image2) btn1.configure(state=NORMAL,background='red' ) btn1.pack() [/code] This is basic and works fine. The issue I am having is that after the button is …

Member Avatar for mawe
0
3K
Member Avatar for trihaitran

My *.py script has some non-ASCII characters in comment lines and when I run it I am getting the following warning: sys:1: DeprecationWarning: Non-ASCII character '\xe5' in file /Users/haitran/Documents/Sophomore UCB/Python/cedict.py on line 118, but no encoding declared; see [url]http://www.python.org/peps/pep-0263.html[/url] for details The thing is I went to the indicated page …

Member Avatar for trihaitran
0
149
Member Avatar for babutche

Hello, I am trying to create a program that uses a dictionary to associate American states with their capitals. It has an interactive loop that exits when the user enters "quit". The user types the name of the state and the program responds with the state's capital. I will show …

Member Avatar for babutche
0
6K
Member Avatar for ribot

Hello! I'm trying out the python irclib and it's working fine. I have noticed that when I run my program there is a text cursor displayed under the outputs from print. I can print text there and nothing happens. I wonder how I can use this printed text in my …

0
84
Member Avatar for sneekula
Member Avatar for Ene Uran
0
13K
Member Avatar for wandie

I have made a list of names and everytime i want to select a value in the listbox it should give me a result in the Entry box can someone please help me. This is my listbox values [code] musicfolder = [ ["CollegeRock/"], ['RnB/'], ['HipHop/'], ['Build/'], ['Buy/'], ['Techno/'], ['Jazz/'], ['Classic/'] …

Member Avatar for wandie
0
5K
Member Avatar for mattyd

Simply, I need to understand the basics of button binding. I have researched [URL="http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm"]this[/URL] already and have decided just to ask for instruction. For example, one of the programs I am building currently will require, at a certain point, user input; I want to be able to know when a …

Member Avatar for sneekula
0
90
Member Avatar for Matt Tacular

I have searched google, but found nothing, I'm not even sure if this is what you call it. But in my program I am writing, if someone hits enter by mistake without entering anything, it errors, is there a way to avoid that? Another error that happens is if the …

Member Avatar for bumsfeld
0
181
Member Avatar for babutche

Hi, I cannot figure out why my fib problem is giving me the output below. I just want it to print when the fib is called and the value of n, when it returns and with what value of n, and the return value. This is what I have so …

Member Avatar for babutche
0
123
Member Avatar for babutche

Hi, I am trying to figure out how to print tracing information for Fibonacci numbers. output = Computing fib(4) Leaving fib(4) returning 3 Can anyone steer me in the right direction? This is what I have: [code]import math def fib(n): if n < 3: return 1 while n >= 3: …

Member Avatar for woooee
0
104
Member Avatar for bud594

I seem to have an intermittent issue with the following code segment. I am installing an application which has an associated excel add in which I register and then run the on open macro. The formula then calls one of the functions from the add-in. The script fails at the …

Member Avatar for bud594
0
749
Member Avatar for Matt Tacular

is there an easy way to detect if the entire contents of one list are in another? if I have a list like this: li = [1,2] and I have another which will have random values, I want the program to do something only if every value of li is …

Member Avatar for vegaseat
0
167
Member Avatar for mattyd

Hello: [I]** I have been researching and experimenting with this with tutorials from many sources but can not even begin it to get it to work it seems.[/I] I have a very small yet important Python program that I must make into an executable file within a week's time or …

Member Avatar for vegaseat
0
274
Member Avatar for babutche

Hi Everyone! I need a little help with this problem. I am trying to import a class -- Student with object makestudent but I keep getting this error: [CODE]This program sorts student grade information Enter the name of the data file: p2sortin.py Traceback (most recent call last): File "C:\Python23\p2sort.py", line …

Member Avatar for Ene Uran
0
135
Member Avatar for babutche

This is what I have come up with but it seems like there should be a more simple way of programming it. [CODE]import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) self.qpoints = float(qpoints) def getName(self): return self.name def getHours(self): return self.hours …

Member Avatar for babutche
0
109

The End.