2,190 Posted Topics

Member Avatar for Atistus

[QUOTE=;][/QUOTE] Try [CODE]if userInput in ['r', 'R']: # ----- or ----- if userInput.lower() == "r": [/CODE]

Member Avatar for TrustyTony
0
140
Member Avatar for jacksparrow01

I used a for loop just for a little variety. And I would also think it should be (but that is just my opinion) [CODE]p p l l aa <-- not reversed cc <-- reversed e e s s [/CODE]

Member Avatar for jacksparrow01
0
172
Member Avatar for joeywheels

[QUOTE]tuple_dict = {} receives "TypeError: unhashable type: 'list'"[/QUOTE] I would suggest that you print the values and note also that a list can not be used as a dictionary's key. If that is indeed what you want to do, convert to a tuple first. [CODE]def histogram(s): tuple_dict = {} ## …

Member Avatar for TrustyTony
0
1K
Member Avatar for e-papa

[QUOTE=;][/QUOTE] And please do a reasonable number of tests of your code before posting. This is a truncated version of the function to point out the error: [CODE]def isprime(n): for ctr in range(2,n): ## do not use 'i', 'l', 'O' as they can look like numbers if n%ctr==0: return 'Not …

Member Avatar for e-papa
0
221
Member Avatar for e-papa

This code can be simplified. [CODE]if 2 <= c_no <= 10: gpa(c_no) # ## replaces, (and note that the "pass" does nothing) if c_no==2: #if the no of courses inputed is 2 gpa(2) elif c_no==3: #if the no of courses inputed is 3 gpa(3) elif c_no==4: #if the no of …

Member Avatar for TrustyTony
0
6K
Member Avatar for bwbyron

The "self.deck.deal([player])" would be a good place to check except self.deck, self.deck = BJ_Deck(), does not have a deal() function. Generally you want to check every time before you deal or hit as you will also catch it if the burn card or the hit card reduce the deck to …

Member Avatar for woooee
0
320
Member Avatar for alokdhari

[QUOTE=alokdhari;1515806]n yea... m new to python !![/QUOTE]This is not high school nor does anyone want to become a personal assistant for the lazy [url]http://tinyurl.com/6eavfzu[/url]

Member Avatar for alokdhari
0
210
Member Avatar for spe_eddy

What does the function normDistProb return? The first attempt to debug this should be to print it [CODE]for i in range(0,12): listProbFog.append(normDistProb(dayValues[i], fogAve[i], fogVar[i])) print normDistProb(dayValues[i], fogAve[i], fogVar[i]) print listProbFog # the other lists are just extra cruft until you get this problem solved [/CODE]

Member Avatar for TrustyTony
0
182
Member Avatar for Thropian

[QUOTE=;][/QUOTE] You have to retrieve and store the RadioButton object. This code stores the grid() object: [CODE]# Radiobutton(canvas, variable=xy, value=x,command=self.move).grid(row=row,column=column) # # instead use # self.rb =Radiobutton(canvas, variable=xy, value=x,command=self.move, image=xxx.) self.rb.grid(row=row,column=column) # using "row" and "column" as names is confusing # # and then self.rb.configure(image=yyy) [/CODE]For configure options see [url]http://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tk/button.n.html[/url]

Member Avatar for Thropian
0
126
Member Avatar for doomas10

[QUOTE=;][/QUOTE] Split() each record. Don't use the first element of the list, join([1:]), in the first file. And, similarly, don't use the last element in the second file.

Member Avatar for TrustyTony
0
229
Member Avatar for spe_eddy

[QUOTE=;][/QUOTE] [QUOTE]there are 31 days in the month so i'm trying to take the last 5 days in this case[/QUOTE]That would be something along the lines of: [CODE]print range(32)[-5:][/CODE]

Member Avatar for spe_eddy
0
145
Member Avatar for blacknred

[QUOTE=tonyjv;1510895]Use 'quotes as outer quotes or double the " inside quotes.[/QUOTE] What space? [CODE]str_out = 'cat /home/myfile.txt |grep -m 1 "my game" ' ## ^<-- this space??? proc = subprocess.Popen([str_out], stdout=subprocess.PIPE, shell=True) # # in Python found = False for rec in open("/home/myfile.txt", "r"): if (not found) and ("my game" …

Member Avatar for TrustyTony
0
164
Member Avatar for leeggodfrey

Try it the other way around? [CODE]inCur = gp.SearchCursor(myFeatureClass2,'COLLECTED_BY = "%s"' % (str(Name)), \ "", "", "DATE_COLLECTED A") [/CODE]Generally, the name is also stored as "obrien" so you can find O'Brien, O'brien, Obrien, etc. I don't know if this is possible here or not.

Member Avatar for leeggodfrey
0
171
Member Avatar for G_S

Also, form the habit of using a list instead of if/elif. It is more straightforward as all of the conditions are on one line. And verb[-2:] is just shorthand for verb[-2:len(verb)], just as verb[:-2] is shorthand for verb[0:-2]. [CODE]verb = input("Write the verb here: ") if verb[-2:] in ['ar', 'er', …

Member Avatar for G_S
0
23K
Member Avatar for pythonbegin

[QUOTE=;][/QUOTE] A second dictionary is not required. Create a tuple containing item1 and item2 and look up in the dictionary. If found, you have a match. If you want to keep the keys in the same order as the file, use the [URL=http://code.activestate.com/recipes/107747-ordered-dictionary/]ordered dictionary[/URL]. For Python 2.7 it is in …

Member Avatar for griswolf
0
1K
Member Avatar for constntine

If you are confident that the string is not wrap- ped around (on 2 lines), then reading the file one record at a time and searching it is the accepted way to go. You have to look at every character in the file no matter how you do it.

Member Avatar for snippsat
0
541
Member Avatar for kur3k

You must install the version of PIL for the Python version that you have on your system. You are trying to install PIL for Python2.6. Python2.6 can not be found on your system. Keying "python -V" (capital V, not lower case) on the command line will give you the Python …

Member Avatar for woooee
0
118
Member Avatar for Fo.katia

[QUOTE=;][/QUOTE] An example for splitting a sentence [url]http://www.java2s.com/Code/Python/String/Asentenceissplitupintoalistofwords.htm[/url]

Member Avatar for griswolf
0
144
Member Avatar for joeywheels

[QUOTE=;][/QUOTE] You never exit the "while True" so it is an infinite loop. Once you eliminate that, you should be able to print the final word_list list which will be a series of numbers. Sort the list and count each of the sequences of the same number. You should also …

Member Avatar for richieking
0
2K
Member Avatar for Archenemie

[QUOTE=;][/QUOTE] I am aware of 2 existing packages, [URL=http://www.parallelpython.com/]parallel python[/URL] and [URL=http://github.com/mattharrison/coreit]coreit[/URL], but haven't tried either. Let us know how it goes.

Member Avatar for richieking
0
133
Member Avatar for Emred_Skye

[QUOTE=;][/QUOTE] You want to start testing at the third element & checking the prior two. What you have will error because when the last element is reached, there is no +1 (also do not use "i", "l", or "O" as single digit variables as they can look like numbers). [CODE]## …

Member Avatar for griswolf
0
137
Member Avatar for bertm81

You should state what it is you want to do. No offense but there are other solutions and perhaps someone here can come up with a workable solution. Generally you would use (although I can't really understand what you are asking): [CODE]class myClass: def __init__(self, methodName="This is the result"): self.methodName …

Member Avatar for bertm81
0
222
Member Avatar for kinto

[QUOTE=;][/QUOTE] Isn't nodeTable a list of classes? So you would access it like this: [CODE] for node in nodeTable: #if node != 0 and Node.visited == False: #nearestNode = node[theNetwork] #listOfNeighbours.append(nearestNode) print node.distFromSource, node.previous. node.visited [/CODE]That is if your class is constructed correctly, which it is not, so that is …

Member Avatar for kinto
0
232
Member Avatar for kinto

[QUOTE=;][/QUOTE] You have to define current distance from source, or distance for pairs, i.e. from node1 to node2 = x, node2 to node3 = y, etc.

Member Avatar for woooee
0
170
Member Avatar for laroca

[QUOTE=;][/QUOTE] [QUOTE]1) change the button sizes to be all the same size (buttons are labeled decrease, surrender, remain, etc...) [/QUOTE]You can use width and height on buttons the same way as done with Text in your program. Reference sites [URL=http://infohost.nmt.edu/tcc/help/pubs/tkinter/index.html]here[/URL] and [URL=http://effbot.org/tkinterbook/]here[/URL][CODE]from Tkinter import * class PreferencesWindow(object): def __init__(self, master): …

Member Avatar for woooee
0
263
Member Avatar for doomas10

Split on "study", or a normal split on space(s) will also work as the number.txt will be -1, or the study's description will be everything except the last element.

Member Avatar for doomas10
0
191
Member Avatar for Thropian

[QUOTE=;][/QUOTE] A second way is to use a StringVar(). See the "textvariable" write up at [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/button.html[/url]

Member Avatar for Thropian
0
662
Member Avatar for Behseini

You can't combine grid() and pack() but must use one or the other. Also, AFAIK, one radio button must be selected (a default selection or you can't choose 'none' when using radio buttons), and the others can be deselected. [CODE]from Tkinter import * class App: def __init__(self, parent): self.my_parent = …

Member Avatar for Behseini
0
5K
Member Avatar for Peacer

You will have to put trace points in your program to see where it is hanging. I doubt it is here. Also, do not use "list" as a variable name as it is already used to name a function that returns a list, and that could be the problem because …

Member Avatar for Gribouillis
0
195
Member Avatar for Michael_Knight

These are quotes for anyone who hasn't heard of Steven Wright. # "I spilled spot remover on my dog. Now he's gone." # "I stayed up all night playing poker with tarot cards. I got a full house, and four people died." # "I'm living on a one-way dead-end street. …

Member Avatar for happygeek
0
1K
Member Avatar for Dogge3

Code tags added. [QUOTE=Dogge3;1493407]I want to create a function wich prints all numbers over 1000000. So the user can input for example 500 and that dosent print but if you input 1005000 it prints. My code far is. [/QUOTE] [CODE]v = [600,6300330,47, 1000001] for x in v if x >1000000: …

Member Avatar for woooee
0
70
Member Avatar for eva yang

There is a discrepancy in these 2 statements. Is preorder a list, so preorder[0] can be None, or is preorder a string, i.e the second statement below? [CODE] if (preorder[0] or inorder[0]) is None: if preorder is not None: [/CODE]

Member Avatar for bron92
0
189
Member Avatar for toritza

Run the input files one at a time, i.e. run the program using the first file and check the output, then run the program again using the second file and check the output file, etc.

Member Avatar for toritza
0
184
Member Avatar for jamseyjames

Use a for() loop with step=3. [CODE]DNA= "ATCGATCGATCGATC" for ctr in range(0, len(DNA), 3): print DNA[ctr:ctr+3] [/CODE]

Member Avatar for Gribouillis
0
108
Member Avatar for yamiyuka

The health variable would be the same as the location and inventory variables. Using a class makes this simple. Instead of "money", "rope", "shiny_stone", etc. I would suggest using a dictionary. [CODE] vars_dict = ["money":[0, "5 dollars sits upon the dresser."], "rope":[0, "a pile of tangles rope is in the …

Member Avatar for yamiyuka
0
597
Member Avatar for fsl4faisal
Member Avatar for woooee
0
165
Member Avatar for RICH148

Test the code you have before posting it here. For example, in the Deck class, there is an indentation error, and the variable "c" [c = Card(rank, suit)] is an instance of the class Card. To access the rank and suit from the Deck class, you would use self._cards[ctr].rank and …

Member Avatar for bpatt22
0
235
Member Avatar for joeywheels

I'm not sure I understand your question but if you want to use multiple class instances, one per dog, try something like this. [CODE]if __name__ == "__main__": dogs = list() dog_name = "" first_inp = "Name: ('quit' to exit) " second_inp = "Breed: " while dog_name.lower() != "quit": dog_name = …

Member Avatar for woooee
0
153
Member Avatar for canyvr

[QUOTE]However,i only can not figure out.....am I stupid??stupid logic?? can anyone help me?It is urgent..[/QUOTE]No one cares if you are stupid or are stupid twice and have waited 'till the last minute. Ask a specific question. For starters, break this into functions. For example, use one function to choose a …

Member Avatar for woooee
0
128
Member Avatar for stefh
Member Avatar for stefh
0
440
Member Avatar for Archenemie

[QUOTE]try and convert the value from the numctrl to a decimal[/QUOTE]You can not convert a float to decimal.Decimal because floats are inaccurate past a certain number of digits. You will have to get/enter the value as a string and convert.

Member Avatar for zentraders
0
295
Member Avatar for Borzoi

It is getting difficult to tell if something is a duplicate. What always runs but never walks, often murmurs, never talks, has a bed but never sleeps, has a mouth but never eats?

Member Avatar for Borzoi
0
745
Member Avatar for Archenemie

To be complete, Linux requires style=wx.TE_PROCESS_ENTER [CODE]import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, -1, mytitle, size=mysize) self.SetBackgroundColour("white") s = "Enter the price:" label = wx.StaticText(self, -1, s, pos=(10,10),) self.edit = wx.TextCtrl(self, -1, pos=(10, 30), \ size=(100, 25), style=wx.TE_PROCESS_ENTER) # respond to enter key when focus is …

Member Avatar for Archenemie
0
4K
Member Avatar for ijessiichan

Use a while() loop that checks for the answer. Also, you should print what options are available as an answer instead of making the enterer guess. This is not intended as a complete answer. [CODE]while intro not in ["yes", "no"]: intro = input("Want to play a game of number guess? …

Member Avatar for woooee
0
190
Member Avatar for stefh

You should use a dictionary for all queries, deletes, etc. %s opens the DB to SQL injection.[CODE]c.execute("select titre, code, date from codes where id=:d_key", {"d_key":idrow}) x=cur.fetchall() # # multiple select fields c.execute("select titre, code, date from codes where id=:d_key and col=:d_col", {"d_key":idrow, "d_col":column_var}) # c.execute("delete from codes where id=:d_key", {"d_key":idrow}) …

Member Avatar for stefh
0
666
Member Avatar for Vertana

join() interleaves a list with a constant so self.currentOutDir.join(self.counterStr) would produce self.counterStr[0]+self.currentOutDir+self.counterStr[1]+self.currentOutDir+self.counterStr[2]...etc. A simple example: [CODE]x = ["1", "2", "3"] print "a".join(x) # x = "123" print "b".join(x) [/CODE]

Member Avatar for Vertana
0
1K
Member Avatar for Greyhelm

You would first compare the ID returned to record[0], the original ID. If it has changed, you can use UPDATE [CODE]cur.execute("UPDATE People SET SQL_id_tag==:update_id", {"update_id": new_id_variable}) con.commit() [/CODE]

Member Avatar for richieking
0
4K
Member Avatar for neroth

This just says that there is no column in the DB named "a.sequence". There is no way to tell any more from a single line of code.

Member Avatar for neroth
0
312
Member Avatar for Thropian

You are obviously not passing the ball object to Bounce ([URL=http://www.python.org/dev/peps/pep-0008/]Python naming conventions[/URL]), so look at the places that call Bounce and see if the ball object is actually being passed.

Member Avatar for Thropian
0
1K
Member Avatar for aldusforte

[QUOTE]The errors I receive: shutil.copy(files, dest)[/QUOTE]Print "files" and "dest" somewhere in the program, also type(files), type(dest); [QUOTE]TypeError: cannot concatenate 'str' and 'list' objects[/QUOTE] to see which is not a string

Member Avatar for aldusforte
0
392

The End.