2,190 Posted Topics

Member Avatar for Thropian

See geometry strings [URL=http://infohost.nmt.edu/tcc/help/pubs/tkinter/std-attrs.html#geometry]here.[/URL] "Geometry" sets the size and location of a widget.

Member Avatar for woooee
0
1K
Member Avatar for txwooley

You should sort both words and compare. Your code will compare "a" to "aa" and find them equal. Note that any anagram program will take "odg" and return "god" and "dog" which is all it can do. [CODE]infile = open ("/usr/share/dict/american-english", "r") ## "dict" is a reserved word words_in = …

Member Avatar for txwooley
0
375
Member Avatar for Gribouillis

Consider posting this in the tutorials forum also so we can find it later [url]http://www.daniweb.com/tutorials/forum114.html[/url]

Member Avatar for woooee
1
1K
Member Avatar for longlongsilver

move() should probably receive a distance parameter. You might use something like this, although it is not obvious from the question what the fuel and distance moved relationship is. [CODE] def move(self, distance): ## do you want to use floats or integers here? fuel_used = distance / miles_per_gallon if self.fuel-fuel_used …

Member Avatar for TrustyTony
0
158
Member Avatar for kur3k

You possibly want to use a Frame widget. One of the online references is [URL=http://effbot.org/tkinterbook/tkinter-index.htm#class-reference]here.[/URL]

Member Avatar for kur3k
0
86
Member Avatar for HoneyBadger
Member Avatar for ekkanh

There is no real difference: [CODE]if condition == True: if condition == "True": [/CODE]

Member Avatar for ekkanh
0
237
Member Avatar for sravi.pearl

What exactly are you looking for and what exactly to do want to replace it with? You can also use string.find which will return the starting position or -1. If you want to remove "The POST" and "is vulnerable" then replace() is the simplest way to go.

Member Avatar for woooee
0
93
Member Avatar for arun_gan

How to start programming is not within the scope of most forums. Start with a tutorial [url]http://www.pasteur.fr/formation/infobio/python/ch11s02.html[/url] [url]http://www.freenetpages.co.uk/hp/alan.gauld/tutloops.htm[/url] [url]http://wiki.python.org/moin/BeginnersGuide/NonProgrammers[/url] We can and will help with code that is formated properly but does not function as expected.

Member Avatar for TrustyTony
0
2K
Member Avatar for s0ur

[quote]I get a result of an integer 1 - 5, say 3 - I would then like the script to tell me what string is assigned to it, in this case 'a'...[/quote]Except that no one realized that the dictionary is bass-ackwards. [CODE]ltr_dic = {1: 'a', 2:'a', 3:'a', 4:'b', 5:'c'} # …

Member Avatar for s0ur
0
190
Member Avatar for fraky

You can use a tuple of the first 3 columns as a dictionary index. [CODE]f_list=open(sys.argv[1]).readlines() ## you can use a set or dictionary unique_dic = {} for rec in f_list: sub_str = rec.split() key = (sub_str[0], sub_str[1], sub_str[2]) if key not in unique_dic: unique_dic[key] = 1 for rec in open(sys.argv[2]): …

Member Avatar for TrustyTony
0
144
Member Avatar for HoneyBadger

Add some printing to figure out what you are testing. Link to [URL=http://diveintopython.org/file_handling/for_loops.html]iterating through lists[/URL]. [CODE]def e_words(m): forbid = 'e' word = m.split() print "testing", forbid, "in", word if forbid in word: return forbidword [/CODE]

Member Avatar for TrustyTony
0
189
Member Avatar for James0l9l

I think the problem may be that you are not entering "N" for the "do you want to go first" question as you have an infinite while loop, and not one the doesn't repeat. The main problem with this code is that you have 54 lines of code that have …

Member Avatar for woooee
0
102
Member Avatar for pacers10

Post some trial code for as much of "A. put all words in lower case and omit all punctuation" as you can so we have something to comment on. "put all words in lower case" = use the lower() function "omit all punctuation" = loop through the text and omit …

Member Avatar for woooee
0
135
Member Avatar for ekkanh

Take a look at [URL=http://www.daniweb.com/forums/thread173615.html]this previous post[/URL]

Member Avatar for woooee
0
63
Member Avatar for marf

[QUOTE]It will Only proceed to execute background.start() when I press "Control + C" to terminate, and it then spews out the ls and then the final print statement.[/QUOTE]Can you run the thread from GTK, say when someone presses a button? Obviously GTK's locks prevent what you are doing. Running it …

Member Avatar for snakerdlk
0
317
Member Avatar for jrp370

[QUOTE]i dont know how to make it produce 2d movements[/QUOTE] If you have an graph with an x and y axis, you can advance in a postive or negative direction for either axis. To keep it simple, point 1=(3,1) for x and y, point 2=(-3, 2) for x and y, …

Member Avatar for group256
0
97
Member Avatar for ljjfb

I use os.kill(), but some of these are OS dependent and Python version dependent. Take a look at [URL=http://www.doughellmann.com/PyMOTW/subprocess/index.html#module-subprocess]Doug Hellmann's examples[/URL] for starters.

Member Avatar for ljjfb
0
16K
Member Avatar for hnnh_km

Code this one step at a time. So first, get the input and check that it is indeed 'r', 'p', or 's'. Then generate a random choice for the computer, etc. BTW you have a lot of redundant code in this function. [CODE]def play_RPS(x, num_games): print 'Press q at any …

Member Avatar for woooee
0
142
Member Avatar for LoveMyPadres

You are continually drawing one oval on top of another, so Tkinter has to keep track of more and more widgets, not to mention that you could reach the recursion limit. Change the color instead. This code is a little crude, but I don't have any time right now. [CODE]import …

Member Avatar for LoveMyPadres
0
2K
Member Avatar for Asset

[QUOTE]but it is obvious I'm too dum to learn [/QUOTE]or to use a spell-checker. Converting from one data type to another is called [URL=http://www.pasteur.fr/recherche/unites/sis/formation/python/ch02s07.html]"type casting"[/URL], so to an integer would use int(). [CODE] str_list = ["1", "3", "5"] for x in str_list: print x, type(x) print int_list = [int(x) for …

Member Avatar for Asset
0
713
Member Avatar for Nassarofficial

[CODE]for lines in textf: if ask in textf:[/CODE]Print "textf" before the "if" statement so you know what you are testing. Using logic like this, entering a word like "the" will find "the", "then, "either", etc. You might want to split the file input into words and check for equal condition …

Member Avatar for griswolf
0
96
Member Avatar for Seagull One

This is left bit shift [CODE]while Step << 32: # while Step < 32: ## instead? [/CODE]If you want to increase the speed of a motor, at higher motor speeds the same increase will yield a greater increase in the speed of the motor because of the initial friction which …

Member Avatar for woooee
0
194
Member Avatar for j855

1) Choose a title that will get people to read the question 2) Sort the list and replace the first 5 numbers with the last 5

Member Avatar for TrustyTony
0
113
Member Avatar for masumar

The easiest way is to use Python's count() function (and then test for a result > 0) for smaller groups of numbers. Some info on [URL=http://effbot.org/zone/python-list.htm]using lists[/URL]. A list can also be used by element or index number. Element[0] = the number of zeros found, element[1] = number of ones, …

Member Avatar for TrustyTony
0
429
Member Avatar for br0wnm4n

Excuse me for butting in, but this is poor style. Try instead: [CODE] for word in words: if word not in d: d[word] = word [/CODE]

Member Avatar for TrustyTony
0
120
Member Avatar for bambi231991

Yes, both can be done. You would use a for() loop to traverse the strings, or convert to a list, in both cases.

Member Avatar for TrustyTony
0
127
Member Avatar for sijei

[quote]Id like it to look like this Multiply ,x times ,y[/QUOTE]See [URL=http://docs.python.org/release/2.5.2/lib/typesseq-strings.html]string formatting[/URL]. [CODE]print "Multiply", x, "times", y print "Multiply %d times %d" % (x, y) [/CODE]

Member Avatar for TrustyTony
0
127
Member Avatar for Chrisfs

Generally, an IDE has a "convert tabs to spaces" option which takes care of this, and I show tabs in lines 11 and 12.

Member Avatar for woooee
0
1K
Member Avatar for akkarin1313

[QUOTE]whenever i add in line "n = fin.readline()", i get an Mixed Iteration variable error:[/QUOTE]for line in fin: and n = fin.readline() do the same thing. Choose one or the other. You can also do a for line in open("constitu.txt"): (is the same thing) as well. Also, a hint below. …

Member Avatar for woooee
0
2K
Member Avatar for novice20

[QUOTE] How to add an entry to the file /etc/apt/sources.list[/QUOTE]sources.list is a list of the repositories to search. It has nothing to do with the individual packages. Try 'man dpkg' and you should find something similar to (I don't remember the exact syntax for dpkg) dpkg -f package_name which you …

Member Avatar for npmaier
0
178
Member Avatar for bpross22

The problem here is not getting records from the file. The problem is that you have large blocks of untested code. I am adding one print statement and a list declaration as a hint: [CODE] def read_from_file(self,room_table): if room_table is not None: fp = open(room_table, 'r') file_list = fp.readlines() fp.close() …

Member Avatar for woooee
0
214
Member Avatar for spacemanspiff92

Try this first: [CODE]def main(): fileInput = 'PlayerNames.txt' wordList=[] print exportTextList(fileInput, wordList) ## <----- [/CODE]and then see the "gc_counter" function [URL=http://www.pasteur.fr/formation/infobio/python/ch01.html#d0e115]here.[/URL]

Member Avatar for richieking
0
120
Member Avatar for pacers10

[QUOTE]_tkinter.TclError: couldn't open "horse.gif": no such file or directory[/QUOTE]It could not open the file. Try it with the complete path.

Member Avatar for woooee
0
142
Member Avatar for king_koder

See [URL=http://www.daniweb.com/forums/thread320708.html]this link[/URL]. The same question (summing items) was asked 2 days ago.

Member Avatar for woooee
0
180
Member Avatar for shashi86

I like using deque's appendleft for coding reverse sequence. You would of course use loops for row and column and eliminate the redundant statements here: [CODE]from collections import deque ctr = 12 print_list = deque() print_list.append(ctr) ctr -= 1 print_list.append(ctr) ctr -= 1 print_list.append(ctr) ctr -= 1 print print_list print_list …

Member Avatar for TrustyTony
0
190
Member Avatar for patto78

You don't return or receive anything for numbers not equal to zero. The function calls itself many times. Each function call must receive the return value when the function it calls finishes, and then return that value to the function it was called by. [CODE]def recursion_test(value): """ recursion example incrementing …

Member Avatar for patto78
0
205
Member Avatar for Mr Tk

Or use something like easyGUI or Tkinter. [CODE]import easygui """ test of multi-enter box """ def multeasygui_date() : title = "Date" msg = "Enter Date" fieldNames = ["mm","dd","ccyy"] fieldValues = [] # we start with blanks for the values fieldValues = easygui.multenterbox(msg,title, fieldNames, fieldValues ) #---------------------------------------------------------------- # from here down …

Member Avatar for Mr Tk
0
3K
Member Avatar for knan

[QUOTE]File "<stdin>", line 11 t1.append(list[temp]) [/QUOTE] "list" is a function so it should be t1.append(list(temp)) In the future, if there is an error for a compound statement, break the statement into it's individual parts to see which part is causing the error.

Member Avatar for Gribouillis
0
158
Member Avatar for Shlaa

See [URL=http://www.daniweb.com/forums/thread320234.html]this link[/URL] for the same question.

Member Avatar for Shlaa
0
138
Member Avatar for -ordi-

Assuming k is an integer, it will never be less than "n" because "n" is a string, as already stated. Print both "k" and "n" to test.[CODE]def otsi(k): if (k < n): print "k < ", k, n # # instead of recursion you should be using a while loop …

Member Avatar for woooee
0
137
Member Avatar for sss33

Double check your average calculations, as generally you can not add averages together. See [URL=http://www.greenteapress.com/thinkpython/html/book006.html#toc53]"Conditionals" here.[/URL] [CODE]if average > 90: grade = "A" Etc [/CODE]

Member Avatar for sss33
0
95
Member Avatar for knan

A place to start, without coding the solution for you. Post your code for help with further problems. [CODE]main_list = [['a', 'b', 'c', 'd'], ['e', 'f'], ['g', 'h']] for each_list in main_list: print "\n New List" for ctr in range(len(each_list)): print ctr, each_list[ctr] [/CODE]

Member Avatar for Gribouillis
0
152
Member Avatar for sravi.pearl

I don't use MySQL, but try using this line instead and see what happens. [CODE]abc = "SELECT * FROM Details" records = cursor.fetchall() [/CODE] and is the table named "Details" or "mydb".

Member Avatar for sravi.pearl
0
207
Member Avatar for ChaosKnight11
Member Avatar for kafro

What happens if you have more than one key with the same maximum? Instead of print, store the key and item if it is greater than the maximum so far.

Member Avatar for kafro
0
128
Member Avatar for gis-brad

You can use split() if I understand correctly. [CODE]locTextFormat = "COUNTY --- TOWN" print locTextFormat.split("---") ## ## or is it COUNTY = "test_county" TOWN = "test_town" print COUNTY + " --- " + TOWN print "%s --- %s" % (COUNTY, TOWN) [/CODE]

Member Avatar for gis-brad
0
298
Member Avatar for pacers10

[QUOTE]I am still getting a systex error when closing the file[/QUOTE]We can't really guess what that is. Post the entire error message. As a general rule, check that line of code and the previous for the same number of open and closing parens. If there is a paren error on …

Member Avatar for TrustyTony
0
165
Member Avatar for Iron-Man1138

Put the above code in a [URL=http://www.greenteapress.com/thinkpython/html/book004.html#toc28]function[/URL] and then call the function from a loop. You can use one function to get the width or the length as well by passing the maximum allowed value and the literal to print, "Width" or "Length", to the function. Note that the [URL=http://www.python.org/dev/peps/pep-0008/]Python …

Member Avatar for TrustyTony
0
318
Member Avatar for yari

Lists work better IMHO because you can alter each element (letter) individually. This is an example of how you could code a solution using lists. Hopefully some print statements will be enough to append the hyphenated string portion of your code. If not post back with questions. There are some …

Member Avatar for TrustyTony
0
2K

The End.