2,190 Posted Topics

Member Avatar for sys73r

You will use something similar to the following (but this code is not complete), tutorial for for loop at [Click Here](http://www.zentut.com/python-tutorial/python-for-loop/) explaination of list append and extend at [Click Here](http://www.greenteapress.com/thinkpython/html/thinkpython011.html) grades = ['7.0', '7.5', '6.8', '6.9'] for ctr in range(0, len(grades), 2): print grades[ctr], grades[ctr+1]

Member Avatar for David W
0
419
Member Avatar for lewashby

You find the location in the line and then seek in the file using the location found in some unknown line. Choose either the line or the file, for example: ## the following "while" line will exit when artist_string is found ## and so the rest of the code (seek_position, …

Member Avatar for TrustyTony
0
398
Member Avatar for Spencer_3

There is no way to help someone who doesn't have a clue short of a Vulcan mind meld. But e.focus() there is no widget method "focus" [Click Here](http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm and if (user.get(), password.get()) in passwords: we have no idea what is in "passwords" but if it is not a list or …

Member Avatar for woooee
0
4K
Member Avatar for thabo.tman.545

> it runs into an infinite while loop and i am unable to debug it. Add print statements so you know where it is and what the variables contain. Instead of testing for i-1!= -1 (which is the first pass of the for loop) and i/j+1 != 8 (which happen …

Member Avatar for woooee
0
534
Member Avatar for DXNNX

I don't understand the game or what it is supposed to do, but you call clearbotones from c (button press). Shouldn't the color be set in c instead of creating new buttons each time? Hint, you use boton[] list. Add a print statement to clearbotones to print each time the …

Member Avatar for woooee
0
251
Member Avatar for vuze

Post a simple example of what you want to do. 276 lines of code is too much as we are trying to guess from your code what you are trying to do. Note that no sorting is done in the code below and in fact the functions are not necessary …

Member Avatar for woooee
0
348
Member Avatar for georgieporgie

> no idea why my program is not reading the text file correctly I have no idea what that means. Print the entire string you are checking and it will show the problem with the upper/lower/digit statements. The upper and lower may work but the digit will not because the …

Member Avatar for woooee
0
171
Member Avatar for nyfan68

I think most programmers will tell you that the Graphics module is more trouble that it is worth. Here is similar with Tkinter and using "after" for the timing. You can easily get events, like mouse clicks, in Tkinter also [Click Here](http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm) import tkinter as tk import random class App(): …

Member Avatar for Schol-R-LEA
0
299
Member Avatar for abaddon2031

You can tell if a file has been changed by the size of the file and date. Check the os.stat module. st_size will give you the size. And one of the getxxtime in os.path will give you the time [there is more than one](https://docs.python.org/2/library/os.path.html#os.path.getctime)

Member Avatar for abaddon2031
0
224
Member Avatar for krystosan

A simple Google turned up pyQtGraph [Click Here](http://pyqtgraph.org/) and there have to be many other examples out there. Matplotlib is an excellent tool, though not Qt.

Member Avatar for woooee
0
463
Member Avatar for mooseless05

You have check_button() declared twice in the code above. One of them should be deleted. A proof of concept to show that the code is working as programmed (although possibly not as you want). Add a print statement to show the values for GPIO.input(13) and GPIO.LOW. Possibly the else statement …

Member Avatar for woooee
0
262
Member Avatar for j.heller

There is more than one way to skin that cat. I use a tkinter variable and update it. Note that you have to call updater() to get the whole thing started. try: import Tkinter as tk ## Python 2.x except ImportError: import tkinter as tk ## Python 3.x class UpdateLabel(): …

Member Avatar for woooee
0
8K
Member Avatar for j.heller

You have to destroy/quit the Tk() instance. You can not do that because "win" now points to a Toplevel. Give the Toplevel another, unique name. win = Tk() win = Toplevel()

Member Avatar for woooee
0
5K
Member Avatar for j.heller

The button's command parameter http://effbot.org/tkinterbook/button.htm would call a funtion that would open a new Toplevel Gui http://effbot.org/tkinterbook/toplevel.htm

Member Avatar for j.heller
0
402
Member Avatar for abaddon2031

IndexError: list index out of range means that at least one of the items in "x" has less than 3 elements. Before the sort, run some code to print anything with less than 3 elements and decide what you want to do with those records. Note also that this while …

Member Avatar for abaddon2031
0
486
Member Avatar for varshaholla

I don't see the error line in the code you posted either, but in any case in the line im = Image.open(resizelist[val]) resizelist is used to to store images throughout the code and not the file names which are necessary for Image.open(). A simple print statement should help you understand …

Member Avatar for woooee
0
469
Member Avatar for novicecoder10

A guess would be that "newSentence" is used in both loops so contains only the value from the last loop. Or in number = len(sentence) "sentence" is not initialized and still has a length of zero. Convert this code to a function and pass each player's correct-letters-guessed list and the …

Member Avatar for woooee
0
234
Member Avatar for varshaholla
Member Avatar for rbyrd
Member Avatar for kxjakkk

Do you want to include numbers and everything else not in string.punctuation s_nopunct = "".join(c for c in s if c not in string.punctuation).lower() Generally it is better to include what you want instead of excluding a certain set as above, as anything you forgot about is automatically included. s_nopunct …

Member Avatar for kxjakkk
0
644
Member Avatar for Michal_3

Use a function http://www.tutorialspoint.com/python/python_functions.htm and call it as many times as you like import time def print_something(ctr): choices = ["zero", "one", "two", "three", "four", "five", "six"] if ctr < len(choices): print(" This is page", choices[ctr]) else: print("Sorry, but what you have typed in is invalid,\nPlease try again.") ctr=1 print_something(ctr) time.sleep(1.0) …

Member Avatar for Schol-R-LEA
0
2K
Member Avatar for debasisdas

“In religion and politics people’s beliefs and convictions are in almost every case gotten at second-hand, and without examination, from authorities who have not themselves examined the questions at issue but have taken them at second-hand from other non-examiners, whose opinions about them were not worth a brass farthing.” —- …

Member Avatar for James_28
8
17K
Member Avatar for trade19

Your program has many issues. The main problem is that you have many instances of the Tk() class, which leads to unknown results. Use Toplevel to open a new GUI. This is code I have lying around that shows how to use grid_forget. The buttons are stored in a dictionary, …

Member Avatar for trade19
0
175
Member Avatar for trade19

> but has the value of mytik = .16801968 That is a tkinter ID number. mytik = Entry(aApp,textvariable=tik)

Member Avatar for woooee
0
120
Member Avatar for biljith

i=i+b; This will give you the sum of the digits. Add some print statements so you know what is going on.

Member Avatar for ReaseySo
0
271
Member Avatar for karmstrong

This code writes every row to the output file if "cat" is found anywhere in the file. for row in reader: if "cat" in reader: writer.writerow(row) For three different strings, you would use something like for row in reader: found = False for col in row: if col in [string_1, …

Member Avatar for Gribouillis
0
575
Member Avatar for ShawnM9913

"Refurbished" is a crap shoot. I've had good luck where they last as long as a new machine and one that died after a few months. As a general rule the warranty is 90 days so consider a new machine with less than "decent" specs as well.

Member Avatar for ShawnM9913
0
206
Member Avatar for maurice.waka

Also, functions [Click Here](http://www.tutorialspoint.com/python/python_functions.htm) make it easy to test each module individually, and to see things that may be burried in a larger body of code like the duplicate similarity == 100 test here if similarity == 100: name3 = ' '.join(name2[-1:]) for item in name3: if similarity == 100:

Member Avatar for maurice.waka
0
253
Member Avatar for Vish0203

The easiest to understand is to use two loops, the first going up to the halfway point and the second going down. You have to first decide how to find the halfway point for an even or odd number for the size of the mountain (note the use of two …

Member Avatar for wshane796
0
295
Member Avatar for reuben_1

Use Idle to start, as it comes with Python. Later you can move to something else once you know more. [Getting started with Idle](http://www.ai.uga.edu/mc/idle/index.html) (although your version of Python is hopefully newer than the one used in the link). Next start with a tutorial like [this one](http://www.freenetpages.co.uk/hp/alan.gauld/tutcont.htm) There are more …

Member Avatar for vegaseat
0
180
Member Avatar for Vish0203

The problem is here while os.stat(filename).st_size < size: Both input and output are buffered on computers. First create a list of what you want to write and check the size each time. Then use .join() to write the file. Writing each number to the file is inefficient and slower anyway, …

Member Avatar for TrustyTony
0
163
Member Avatar for bnn678

Add the directory to your path then use import program_name. To add it permanently add export PYTHONPATH=$PYTHONPATH:/new/directory/name to your .bash.rc file. To add it for this program sys.path.append("/add/this/directory") See this tutorial [Click Here](http://www.tutorialspoint.com/python/python_modules.htm)

Member Avatar for bnn678
0
245
Member Avatar for a_1

That question was already asked [here](http://www.daniweb.com/software-development/python/threads/470940/multiples-in-desc-order-in-list) with more than enough hints to solve the problem.

Member Avatar for woooee
0
149
Member Avatar for Vish0203

Append the count + word to the new list. words = ["engine","ant","aeiou"] count = 0 vow_count = [] for chars in words: for letter in chars.lower(): if letter in 'aeiou': count += 1 vow_count.append([count, chars]) count = 0 vow_count.sort() print vow_count print [word for count, word in vow_count]

Member Avatar for vegaseat
0
303
Member Avatar for onely

Your code is not anything that can really be corrected. Start with the "Defining Classes" and "Using Classes" [Click Here](http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm) and go on from there Post back once you have the basics down with any further questions.

Member Avatar for woooee
0
184
Member Avatar for yvonne.lundeandreassen.9

I don't know what an ibookG4 is but if it is an Apple product, previous versions should be available in their repos and it would be as simple as telling the software manager to install a particular version. Also, the software manager may have a "revert back to the previous …

Member Avatar for yvonne.lundeandreassen.9
0
176
Member Avatar for Vish0203
Member Avatar for rrashkin
0
244
Member Avatar for charlie1329

You have to explicitly call the init method in child classes. Also, I am guessing that the widgets are not showing because they are not explicitly placed in the root widget. Finally, there is no reason to assign the return of place() to a variable as it is always "None", …

Member Avatar for charlie1329
0
4K
Member Avatar for lewashby

You are printing separate variables. MemberCounter.members is different from m1.members="Two". Print the id() of each, which will show that they all occupy different memory locations. You might also want to study up on the difference between class objects/attributes and instance objects/attributes [Click Here](http://docs.python.org/release/2.5.2/tut/node11.html#SECTION0011330000000000000000) Sometimes you are printing an instance object …

Member Avatar for lewashby
0
182
Member Avatar for Caulm64

You keep track of the smallest and largest in separate fields. A little trick is to initialize both with the first input value since you don't know the range of the input numbers. For example, if you initialize largest to zero, thinking all numbers will be greater, someone could input …

Member Avatar for sneekula
0
10K
Member Avatar for WILLIAM_5

You also have to have TCL and Tk installed. I don't know if it comes with MS Windows or not but this link has a section for installing [Click Here](http://www.tkdocs.com/tutorial/install.html) of[Click Here](http://www.tcl.tk/software/tcltk/) For further help we will have to see more than "module not found" of the error message as …

Member Avatar for nichom
1
632
Member Avatar for aplh_ucsc

> module' object has no attribute 'geteuid' windows There is no "geteuid" in the code you posted. You will have to post the entire error message so we can tell which line it is coming from.

Member Avatar for Gribouillis
0
4K
Member Avatar for Zahra_1

And is input from the command line, or are you using a GUI toolkit to get input and show the dice.

Member Avatar for vegaseat
0
162
Member Avatar for ganapathy24

This homework question comes up every year so there are other posts that you can look at. We do not do your homework for you however. Also, posting on multiple forums reduces your chances for an answer because no one wants to waste time on a question that has possibly …

Member Avatar for ganapathy24
0
295
Member Avatar for vegaseat

64 bit, Python 2.7 is predictably twice the memory, except for the string??? """ Size of empty tuple = 56 Size of empty list = 72 Size of empty dictionary = 280 Size of empty string = 37 """

Member Avatar for Tcll
3
527
Member Avatar for stuartlross

Try using readlines instead, and check that searchWord actually contains something otherwise you can write blanks to the file. with open("SearchText.txt").readlines() as records: for num, line in enumerate(records): ...... ## the following line will yield an error on the ## last record because there is no num+1 response=records[num +1]

Member Avatar for woooee
0
288
Member Avatar for tony75

Traceback (most recent call last): File "C:UserslinuxDesktopscreenshot1.py", line 11, in <module> img.save(SAVE_PATH) Print SAVE_PATH to see what name the program is trying to use (not the one you think it is). Also you can use from os import environ My computer likes environ['HOME'] instead of 'HOMEPATH' but it may be …

Member Avatar for tony75
0
4K
Member Avatar for MrNoobieCoder

Do you mean you want to limit the amout of time the user has to answer the question or something else? A while loop or a 'return' from a function will work to limit the time from datetime import datetime, timedelta import time current = datetime.now() stop = current + …

Member Avatar for woooee
0
307
Member Avatar for dean.ong.14

Running this stripped down version works on my machine from tkinter import * root = Tk() calc = Frame(root) calc.grid() root.title("Calculator") text_box = Entry(calc, justify=RIGHT) text_box.grid(row = 0, column = 0, columnspan = 3, pady = 5) text_box.insert(0, "0") root.mainloop()

Member Avatar for Gribouillis
0
14K
Member Avatar for tunisia

Using partial is easier and makes more sense IMHO [Partial examples](http://pymotw.com/2/functools/) from functools import partial ... ## to send "on" and "host" to callback_power_on function b = Button(master, text="Power On", command=partial(callback_power_on, on, host)) ##---------- or if you prefer ---------------------------- b = Button(master, text="Power On", command=partial(callback_power_on, data=on, host=host))

Member Avatar for woooee
0
384

The End.