2,190 Posted Topics

Member Avatar for Jordan_4

The second return statement in inputPlayerLetter() never executes because the function exits when the first return is called. It should be return Player, Computer And you then have to catch the return when you call the function. See "the return Statement" at this link for a tutorial http://www.tutorialspoint.com/python/python_functions.htm and https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch07s04.html

Member Avatar for woooee
0
392
Member Avatar for qashnfhkh

> don't work this: bg_fon2 = PhotoImage(file='2.GIF') We have no idea what that means. Is it displaying upside down, or cropped, bad colors, etc.

Member Avatar for sneekula
0
139
Member Avatar for EdJones

using main() is a waste as it is the same thing as putting it under `if __name__` etc. Instructors use it to teach students about functions, and always use the same name so as not to confuse them. For "real programmers" each function has a specific function (makes sense) and …

Member Avatar for sneekula
0
147
Member Avatar for itsthewendigo1111

> second it does not give me messages for when a one is rolled or 2 is rolled Do you mean one or two dice are rolled, or the dice rolled total one or two > nor does it go on to the next players turn like its suppose too …

Member Avatar for itsthewendigo1111
0
263
Member Avatar for ao_py

[quote]if door == 1 and b1.clicked(pt): AttributeError: 'NoneType' object has no attribute 'clicked'[/quote]I am not that familiar with the GUI named "graphics", but obviously b1==None which means it has no method clicked, or any other method. Examples of creating buttons exist here on Daniweb as well as on the web. …

Member Avatar for sneekula
0
892
Member Avatar for dancks
Member Avatar for Gribouillis
0
995
Member Avatar for Johnny Blaz

You can use he same variable for the number of spaces to print, see below. If you want to print a total of 40 stars, I can't tell from your code and you didn't explain empty_spaces=0 one_side=7 # stars stars_side=0 incr=1 stars_printed=0 while stars_printed < 40: print "%s*" % (" …

Member Avatar for woooee
0
1K
Member Avatar for JJHT7439

To emphasize what Tony said: [CODE] actorNode = findNode(graph,actorName) if actorNode == None: actorNode = mkNode(actorName) print "created", actorNode graph.append(actorNode) print "graph", graph [/CODE]You want to test each function individually before going on to the next function, or you have 56 lines of code to debug and no idea what …

Member Avatar for James_41
0
3K
Member Avatar for woooee

There aren't that many, and of course this is more for entertainment. I will start it out 1. You didn't post a complete, working example to a homework problem that can be copied, pasted, and handed in.

Member Avatar for almostbob
0
271
Member Avatar for ncassambai

You would have to use multiprocessing for the timer since the program is doing two things, 1. getting the answer 2. moving on/killing the question's process after 30 seconds whether the question has or has not been answered. Multiprocessing takes a little fiddling to get the input in a thread …

Member Avatar for woooee
0
144
Member Avatar for mark103

You create a new list on every pass through the for() loop, so everything except for the final value in the range was garbage collected. Move the ID=[] somewhere outside of the for loop(s) so it contains all values. for channels_id in range(4127, 4548, 70): ID = [] # re-created …

Member Avatar for Gribouillis
0
210
Member Avatar for 4m1nh4j1

I would use a Manager dictionary which would contain 1. a counter or other method that can be easily compared to the original to show that there is a change 2. the configuration See the Managing Shared State heading on Doug Hellmann's site [Click Here](http://pymotw.com/2/multiprocessing/communication.html) This simple example shows that …

Member Avatar for vegaseat
0
2K
Member Avatar for joustwilliams

You have an infinite loop because all of the returns call main() again. BTW main is a bad name for a function because it is not descriptive. Some instructors use it in their beginning courses so as to not confuse the students with functions that have different names. In your …

Member Avatar for vegaseat
0
2K
Member Avatar for bustamorg

You can pass an optional start location to .find() but that means iterating over the entire list several times. Another way word="APPLE" guess="P" hint=["-" for ctr in range(len(word))] print "initial =", hint for index in range(len(word)): if word[index]==guess: hint[index]=guess print "".join(hint)

Member Avatar for bustamorg
0
235
Member Avatar for oussama_1

What, no one has mentioned writing a sloppy, undocumented program because it is a one-time quick and dirty use. Murphy's law says you will still be using that program 10 years from now and it will be much, much longer.

Member Avatar for Warrens80
1
367
Member Avatar for Dawnbox

I would suggest that first you print "i" as it is probably not what you think it is. See [Click Here](http://www.ibm.com/developerworks/library/os-python6/index.html) "for loop and a string" Second, you want to test for limits after the shift. You did not post any code to shift by "b". To eliminate spaces, periods, …

Member Avatar for Dawnbox
0
346
Member Avatar for krishna bharath

Start here with your post [Click Here](http://www.daniweb.com/forums/post3625.html#post3625 )

Member Avatar for HiHe
-2
350
Member Avatar for ddanbe

Conundrum = Trying to fiqure out what Pneumonoultramicroscopicsilicovolcanoconiosis means

Member Avatar for bumsfeld
0
1K
Member Avatar for OnEaglesWingsjf

1. your indentation is not correct (and can not be corrected because you did not say what you are trying to do). 2. you do not import math 3. math does not contain a square_root function. Try help(math) to get a list of built-in functions for math 4. project_to_distance does …

Member Avatar for vegaseat
0
340
Member Avatar for davidbr

grid() returns None so self.label1 equals None in the code you posted. There are two ways to update a label, illustrated below. There is way too much code here for me to traverse so the following is independent of any code you posted. class UpdateLabel(): def __init__(self): self.master = tk.Tk() …

Member Avatar for davidbr
0
8K
Member Avatar for fatalaccidents

You will have to continuously check the status of the processes, or the value of some variable/dictionary/object to know when it changes. You can use is_alive() to check the status of a process in multiprocessing. You could also use a manager.dict() set to True for each processes' key, and have …

Member Avatar for ~s.o.s~
0
5K
Member Avatar for kiddo39

> I've tried a 'for i in range(53):'loop but > that doesn't work for this Why not? It seems like the proper way to do this. Note that you salt the variables with the first 2 numbers, so the loop would run 2 less than the number of the total …

Member Avatar for HiHe
0
241
Member Avatar for ibrahim.sawaneh.16

You would use a list of lists. One sub-list for each row, so if the data is 1, 3, 2, 7, 5 and you are drawing the third row, you would place an "X" in the element at offsets 1,3, and 4 since those 3 all require a third row. …

Member Avatar for woooee
0
107
Member Avatar for psichoman5

puntaje = str(int(A + B + C + D + E + F + G + H + I + J + K + L)) If "B", or any variable is less than 3, then the if statement is not satisfied and B (or any variable) is never declared. Some …

Member Avatar for woooee
0
468
Member Avatar for mark103

The docs are always a good place to start [Click Here](https://docs.python.org/2/library/datetime.html) Strftime is part of the datetime.date class, not datetime.datetime.

Member Avatar for vegaseat
0
1K
Member Avatar for entropicII

PySerial finds the port by he offset so the first port would be offset 0, since it is at the beginning. Port #5 would offset the first 4 ports from the beginning so would be ser = serial.Serial(4, 9600) Take a look at the intro docs [Click Here](http://pyserial.sourceforge.net/shortintro.html) and try …

Member Avatar for woooee
0
2K
Member Avatar for mcroni

I don't see anything in your code that is adding an extension.You might want to use the [FileDialog](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/tkFileDialog.html) module to get the file name. Also note that you have duplicate PhotoImage statements in the program.

Member Avatar for vegaseat
0
279
Member Avatar for Jai_4

If you print "digit" you will see that it goes from right to left so for input that is an even number in length, the code is bass ackwards. Also a=a/10 only executes under the else. Use a for loop instead of a while loop with your logic or something …

Member Avatar for sneekula
0
802
Member Avatar for sneekula

There are several ways to do this. I prefer a while loop ## Not divisible by 3 mylist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] newlist = [] sublist=[] ctr = 0 while ctr < len(mylist): sublist.append(mylist[ctr]) ctr += 1 if not ctr % 3: …

Member Avatar for sneekula
0
260
Member Avatar for La

What does it do differently than what you expect? A simple example with an explanation of what you want will get faster and better results Note that encode_files is declared twice and there are indentation errors in the code.

Member Avatar for vegaseat
-1
679
Member Avatar for rednose00

I would suggest that you first write it out on paper with 2 or 3 actual examples of what you want and then see how the program differs from the actual examples. For example, balance and remaining balance never change, why? How would you keep track of remaining balance when …

Member Avatar for vegaseat
0
2K
Member Avatar for BingityBongity

> using a list, return a 'counterlist' containing all the strings in the original list plus the number of times the string appears in the list You want a list of lists. While the list in your post can work CounterList = ["hello", 1, "hi", 2] a list of list …

Member Avatar for snippsat
0
380
Member Avatar for Reverend Jim
Member Avatar for Reverend Jim
1
392
Member Avatar for Ravi_exact

Cross posted so may have already been answered. Check first so you don't waste your time. http://qt-project.org/forums/viewthread/46750 http://bytes.com/topic/python/answers/958375-how-check-signal-emit-finished-python

Member Avatar for woooee
0
206
Member Avatar for mcroni

> this is where my problem is,,,i cant use this fuction to read from the text file and display the corresponding results in the text widget I don't understand what you mean. Insert is the correct way to insert text into a Text widget. Edit: Ah, you don't call the …

Member Avatar for mcroni
0
721
Member Avatar for La

Please post the entire error message as we have no idea where it may be coming from. The call to encode_files, may be the problem but that code is not included so we can't tell..

Member Avatar for sneekula
-1
233
Member Avatar for chophouse

It is a good idea to strip() a record first, unless you are really really sure of the format. Lambda is a bad habit IMHO. Guido wanted to omit lambda (and map, reduce, & filter) from Python3 because [list comprehension](http://carlgroner.me/Python/2011/11/09/An-Introduction-to-List-Comprehensions-in-Python.html) is faster and the code is easier to understand. So …

Member Avatar for Gribouillis
0
342
Member Avatar for JustinCase58

while not (done): will loop until done==True To get done==True in the code you posted, you have have to enter "s" on your only input line, i.e. choose=input("\nChoose a class please : f=Fighter, m=Magic User ") You can also use a [return statement](http://www.tutorialspoint.com/python/python_functions.htm) to exit the funtion containing the while …

Member Avatar for Jack_9
0
154
Member Avatar for JubalBarca

This code from Vegaseat tells you which key is pressed. You can use a similar function that tests for cetain keys and responds accordingly. I think the general binding is widget.bind("<1>", call_back) (for the number 1). try: import Tkinter as tk ## Python 2.x except ImportError: import tkinter as tk …

Member Avatar for woooee
0
3K
Member Avatar for dumicom

[This example](http://matplotlib.org/examples/api/fahrenheit_celsius_scales.html) from the pyplot examples page, plots two scales, and there are probably more.

Member Avatar for Gribouillis
0
348
Member Avatar for Atomicquasar

"Aligning" depends also on the font used. If you are displaying the result in the console, then the console must use a fixed witdth font. If you want to experiment, save the result to a file, open the file with any text/word processor and change the font from proportional to …

Member Avatar for Gribouillis
0
336
Member Avatar for mark103

We don't know which one of at least 3 or 4 possible statements is causing the error because you did not include the error message. As a shot in the dark I would suggest that you print row or cur or both somewhere around this for() statement cur.execute('SELECT channel FROM …

Member Avatar for woooee
0
2K
Member Avatar for Gribouillis
Member Avatar for lewashby

builtins.UnicodeDecodeError: 'utf-8' Don't know much about unicode but it may be that the OS is not set up for utf8, so include this at the top of the file to let the interpreter know to use utf8, or whatever,instead of the encoding set by the OS when you try to …

Member Avatar for snippsat
0
822
Member Avatar for MartinIT2type

You want to use a class. The variable will be visible and accessible as long as the class exists.[code]from Tkinter import * class Demo: def __init__(self, top): self.name="" frame_e = Frame(top) frame_e.pack() self.t_name = StringVar() text = Entry(frame_e, textvariable=self.t_name, bg="white") text.pack() text.focus_force() nameButton = Button(frame_e, text="Accept", command=self.Naming) nameButton.pack(side=BOTTOM, anchor=S) def …

Member Avatar for jules1234567
0
8K
Member Avatar for Chrome 142

You have to use the get() method of the StringVar. See the second, or get() example at [Click Here](http://effbot.org/tkinterbook/optionmenu.htm) i.e convert from a Tkinter variable to a Python variable

Member Avatar for Chrome 142
-1
406
Member Avatar for mark103

I only know multiprocessing. The example below starts an infinite loop in a process and uses the terminate method to end the thread, which could also be tied to the backspace key, so perhaps you can adapt the program. You should consider experimenting with a simple example to get the …

Member Avatar for DragonMastur
0
477
Member Avatar for iConqueror

And problem solving skills only work when the problem is defined. A well defined problem is 50% solved or more IMHO.

Member Avatar for jwenting
0
224
Member Avatar for krystosan

You would use partial. I don't have Qt installed so can't test, but this should work. Note that if it is self.thrown error, you don't have to pass it to the function as "self" variables can be accessed anywhere within the class. from PyQt4.QtCore import pyqtSignal, pyqtSlot from PyQt4.QtGui import …

Member Avatar for woooee
0
336
Member Avatar for mark103

It is possible that the GUI or whatever that setLabel uses, does not update the screen until the for loop finishes. We don't have enough info to help much further than that as the code is incomplete. Also, please post what you have done to debug this code. If you …

Member Avatar for vegaseat
0
419

The End.