3,386 Posted Topics

Member Avatar for sofia85

line.split(None, 1) to split it and do eval on secoond item off the result. [code]>>> line = "0 ['a', 'b', 'c']" >>> st, seq = line.split(None, 1) >>> seq = eval(seq) >>> st, seq ('0', ['a', 'b', 'c']) >>> [/code]

Member Avatar for sofia85
0
99
Member Avatar for Joey7

Good luck, we help you out if you post enough effort. Add one function at time. I would start from parsing the text and recognizing the tags and tag uses. Split or partition methods would be helpfull. of course you could use also use re module, which would probably make …

Member Avatar for TrustyTony
0
138
Member Avatar for Creatinas

It is common practice to put button to start search if you are not doing incremental search while user is typing. You react to button event, not checking if user typed to inputs. It should not matter if callback function blocks until search is ready. Usually with gui you have …

Member Avatar for Creatinas
0
197
Member Avatar for vlady

You need to set both __add__ and __radd__ and check for other being integer 0, the sum start value. I do not know if this is official way, but it got it to work: [CODE]def int_to_time(seconds): time = Time() minutes, time.second = divmod(seconds, 60) time.hour, time.minute = divmod(minutes, 60) return …

Member Avatar for vlady
0
125
Member Avatar for Stpdoug

This worked for me in Lazarus environment (even it is brittle due to possibility of non-numeric input to number variables) [CODE]program Project1; uses Classes, SysUtils, crt; Var ItemN:array[1..5] of string; UnitP:array [1..5] of integer; Quantity:array [1..5] of integer; UnitT,totalprice,discount:real; index,n:integer; Begin clrscr; Writeln('Group Assignment'); Writeln('----------------'); Writeln('Enter amount of goods'); readln(n); …

Member Avatar for Stpdoug
0
180
Member Avatar for vgd

I doubt "GATE2001" is something what can be put in a char, for example.

Member Avatar for smilenow
0
148
Member Avatar for nanao

It is not chr *v[] This seems to run, performance or also logic I do not know (with code tags and run through Code::Blocks Astyle formatter): [CODE]#include <stdio.h> #include <stdlib.h> void swap(char v[], int i, int j); void myqsort(char v[], int left, int right) { int i, last; if(left>=right) return …

Member Avatar for TrustyTony
0
315
Member Avatar for pseudorandom21

By googling one of the first hits, was [url]http://stackoverflow.com/questions/75705/how-to-read-write-dbase-iii-files-using-c-net-odbc-or-ole[/url] Which has small snippet to try for C#.

Member Avatar for TrustyTony
0
304
Member Avatar for PlUmPaSsChIcKeN

Just use your dictionary, but the last key ':','!', which is tuple when all other keys are string, looks incorrect.

Member Avatar for PlUmPaSsChIcKeN
0
171
Member Avatar for ronnieaka

From [url]http://www.cs.utexas.edu/~cannata/cs345/Class%20Notes/Prolog%20examples.pdf[/url], we find simple recursive fibonacci and also an efficient one: [CODE=prolog]fib(0, 0). fib(X, Y):- X > 0, fib(X, Y, _). fib(1, 1, 0). fib(X, Y1, Y2) :- X > 1, X1 is X - 1, fib(X1, Y2, Y3), Y1 is Y2 + Y3. [/CODE]

Member Avatar for TrustyTony
0
7K
Member Avatar for sys73r

Looks like writer takes sequence of letters and thinks each letter is record, give it a sequence of strings instead.

Member Avatar for sys73r
0
200
Member Avatar for blaze423

Just google 'web camera python' and you find for example one HOWTO: [url]http://technobabbler.com/?p=22[/url]

Member Avatar for ashely97
0
2K
Member Avatar for cloudynight

Why don't read up from internet, like [url]http://ironbark.bendigo.latrobe.edu.au/subjects/PE/2005s1/other_resources/desk_check_guide.html[/url]

Member Avatar for TrustyTony
0
119
Member Avatar for A.D.M.I.N
Member Avatar for TrustyTony

This is my code for anagrams not utilizing the ready prepared file of anagram synonyms to celebrate 11.11.11 11:11:11. If you start program it warns you about missing subdirectory dict and creates it. You may put any word files, one word per line, to file <dictionary name>.txt. Program lists available …

0
2K
Member Avatar for BWall

For me little simpler is to keep set of guessed letters: [CODE]word1 = "hangman" guesses = set() for guess in "abn": print("testing", guess) guesses.add(guess) print(" ".join(c if c in guesses else '_' for c in word1)) [/CODE]

Member Avatar for woooee
0
181
Member Avatar for A.D.M.I.N
Member Avatar for hemant_rajput

Just copy it to Python 3.2 subdirectory Lib/site-packages [url]www.python.org/dev/peps/pep-0250/[/url]

Member Avatar for Gribouillis
0
249
Member Avatar for Tomie

Consonants is one long string which is unlikely to be inside word. Maybe you meant set intersection or not any with generator expression?

Member Avatar for woooee
0
860
Member Avatar for avidthrows

You mean this is outdated? Was in first hit page of Google. [url]http://en.m.wikipedia.org/wiki/CMU_Pronouncing_Dictionary[/url]

Member Avatar for avidthrows
0
110
Member Avatar for rahulroshan
Member Avatar for pelin

name1 = input("Enter your name") def changeName(name): fields = name.split(",") return fields fields = changeName(name1) print(fields[1],fields[2],fields[0]) I can not replicate the error, and please uset the code-tags! You did them, I see, but your code is not between them! Enter your nameVeijalainen, Tony, Jarkko Tony Jarkko Veijalainen

Member Avatar for vegaseat
-1
94
Member Avatar for huntaz556

There should be twice %20s in format, typo of posting without running the code first.

Member Avatar for TrustyTony
0
296
Member Avatar for as3g

I would define the prices in tuples and use for loop iteration over that and one while loop instead of repeating code (of course you could also put it in function). Not to give you too much here is my changed price tuple, which I used to do that to …

Member Avatar for TrustyTony
0
94
Member Avatar for DoubleTapThat

Basically it looks OK, but the banners are excessive especially the last one and you could have used multi-line string for clearer long text message instead of loads of prints. There are couple of code snippets already in the archive, mine is [url]http://www.daniweb.com/software-development/python/code/356952[/url] . Brings nostalgia as this program is …

Member Avatar for TrustyTony
0
320
Member Avatar for beck4456
Member Avatar for arson09

You have at least line 24 incorrectly indented inside the loop. The docstrings are not indented into inside functions. And you are missing the loop to find the correct position to insert the value in insert method; size is returning whole length, not only requested part, remove is missing parameter …

Member Avatar for arson09
0
225
Member Avatar for graphicsgrl
Member Avatar for graphicsgrl
0
954
Member Avatar for ao_py

The idea of strengths of teams is nice, but the method is little intriguing. Considering the case is for two teams competing each other the probability should be ok, just ask probA (as probB would be 1 - probA) and check for [iCODE]if random() < probA:[/iCODE] Input could be in …

Member Avatar for Gribouillis
0
2K
Member Avatar for marco1497

I agree, but interpret this differently. If software engineering does not cover compiler design (even the formulation was quite undecipherable), then it would mean compiler is not software. This is clearly contradiction, so the claim is wrong, compiler is a big program (even with current history of software engineering and …

Member Avatar for JeffGrigg
0
257
Member Avatar for cwarn23

Maybe you could take example of this one about PowerPoint: [url]http://norvig.com/Gettysburg/index.htm[/url] P.S. Please do not read my signature, I am not native speaker. ;)

Member Avatar for NicAx64
0
472
Member Avatar for sitmiller

Why on earth the prompt >>> ? Post indented code from the program file, if code is not experimenting interactively. Push first the code button and ctrl-v the code from clip board. Just take out the global statements and use the return values from function for side effects. Alternatively you …

Member Avatar for woooee
0
203
Member Avatar for peste19

list is builtin type, I do not understand list.items. Your indention also seems incorrect.

Member Avatar for woooee
0
99
Member Avatar for Creatinas

Shouldn't you use the frame instead of creating new MyFrame for each panel?

Member Avatar for Creatinas
0
155
Member Avatar for hhgh4269

How about SetBkColor? [url]http://www.programmersheaven.com/mb/Delphi/361128/361128/setbkcolor/[/url]

Member Avatar for TrustyTony
0
83
Member Avatar for Sprewell184
Member Avatar for Sprewell184
Member Avatar for praveens96

Before paste code push the (CODE) button. Also it is good to give reference in net about the subject, like: [MontyLingua V.2.1 (Python and Java) A Free, Commonsense-Enriched Natural Language Understander for English](http://web.media.mit.edu/~hugo/montylingua/)

Member Avatar for sumitb128
0
627
Member Avatar for rysin

Updated code in the code snippet (need to put bind before withdraw), the tkinter solution here is correct. [url]http://www.daniweb.com/software-development/python/code/360113/1683057#post1683057[/url]

Member Avatar for TrustyTony
0
548
Member Avatar for TrustyTony

This is similar to earlier posts in DaniWeb by vegaseat, but it demonstrates getkey with withdrawn tkinter, restart inside object by re-calling it's __init__ method.

Member Avatar for TrustyTony
2
2K
Member Avatar for Flames91

Your base case is the case with less than two elements in sequence and you should return True if sum of two first ones < 0 or otherwise the result of calling function recursively with smaller of first two in sequence and the other elements.

Member Avatar for arson09
0
777
Member Avatar for mjohnson

You are comparing string from user with binary data. Print values before condition to check what you are comparing. Pin.txt is never used. You should use normal text file.

Member Avatar for mjohnson
0
1K
Member Avatar for bigredaltoid

[CODE]blanklines = periods = 0 with open("advsh12.txt") as my_file: for linecount, line in enumerate(my_file, 1): if line == ('\n'): blanklines +=1 elif '.' in line: periods += line.count('.') for item, count in ('lines', linecount), ('blank lines', blanklines), ('periods', periods): print "The total number of %s in the file is %i" …

Member Avatar for TrustyTony
0
2K
Member Avatar for kwajo

You are creating only one instance of bunny at line 77, also only class namesshould be capitalized You should make list of Bunny instances. Your code I do not understand.

Member Avatar for kwajo
0
487
Member Avatar for sravanthi89
Member Avatar for peste19

I do not understand line 3, I think file class has not csv attribute. n is also never used.

Member Avatar for woooee
0
174
Member Avatar for as3g

When you open file with 'w' it is automatically created provided you give valid path name.

Member Avatar for as3g
0
96
Member Avatar for bigredaltoid
Member Avatar for Dann0

You do not describe your problem. At least many of your ifs should be elifs.

Member Avatar for Dann0
0
198
Member Avatar for strongguy12345

You should take absolute value in distance calculation and you should update the maximum inside while in second code.

Member Avatar for woooee
0
195

The End.