3,386 Posted Topics
Re: 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] | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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); … | |
Re: I doubt "GATE2001" is something what can be put in a char, for example. | |
Re: 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 … | |
Re: 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#. | |
Re: Just use your dictionary, but the last key ':','!', which is tuple when all other keys are string, looks incorrect. | |
Re: 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] | |
Re: Looks like writer takes sequence of letters and thinks each letter is record, give it a sequence of strings instead. | |
Re: Just google 'web camera python' and you find for example one HOWTO: [url]http://technobabbler.com/?p=22[/url] | |
Re: 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] | |
| |
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 … | |
Re: 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] | |
Re: Just copy it to Python 3.2 subdirectory Lib/site-packages [url]www.python.org/dev/peps/pep-0250/[/url] | |
Re: Consonants is one long string which is unlikely to be inside word. Maybe you meant set intersection or not any with generator expression? | |
Re: You mean this is outdated? Was in first hit page of Google. [url]http://en.m.wikipedia.org/wiki/CMU_Pronouncing_Dictionary[/url] | |
| |
Re: 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 | |
Re: There should be twice %20s in format, typo of posting without running the code first. | |
Re: 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 … | |
Re: 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 … | |
Re: Use zip function and for loop. | |
Re: 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 … | |
Re: You must use a while loop and post the corrected code with CODE tags. | |
Re: 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 … | |
Re: 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 … | |
Re: 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. ;) | |
Re: 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 … | |
Re: list is builtin type, I do not understand list.items. Your indention also seems incorrect. | |
Re: Shouldn't you use the frame instead of creating new MyFrame for each panel? | |
Re: How about SetBkColor? [url]http://www.programmersheaven.com/mb/Delphi/361128/361128/setbkcolor/[/url] | |
Re: Use two labels with a image. | |
Re: The parameter is not used so it should be removed. | |
Re: 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/) | |
Re: 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] | |
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. | |
Re: 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. | |
Re: 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. | |
Re: [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" … | |
Re: 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. | |
Re: Did you read my code snippet of sending gmail? Compare it with yours, it works. | |
Re: I do not understand line 3, I think file class has not csv attribute. n is also never used. | |
Re: When you open file with 'w' it is automatically created provided you give valid path name. | |
Re: Line 10 is incorrectly indented inside the for loop. | |
Re: You do not describe your problem. At least many of your ifs should be elifs. | |
Re: You should take absolute value in distance calculation and you should update the maximum inside while in second code. |
The End.