Forum: Python 10 Days Ago |
| Replies: 8 Views: 287 I don't think I understand the second example...
Where'd the 1 come from?
Code comments:
line 6:
data = input("Please enter a string\n")
Should use raw_input to get string data. |
Forum: Python 13 Days Ago |
| Replies: 9 Views: 280 The error you were reporting was based in your original code:
if letters[x] == ' ':
y = 0
message_number.append(y)
x = x+1
if letters[x] == 'A' or 'a':
... |
Forum: Python Mar 31st, 2009 |
| Replies: 12 Views: 776 Maybe you should look at the python bit-wise operators in the Python Docs (http://docs.python.org/reference/expressions.html#binary-bitwise-operations) |
Forum: Python Feb 8th, 2009 |
| Replies: 14 Views: 817 My prototype (really simple -- uses 3 copies of the sample data you posted) seems to work ok. I do parse the first input file 4 times (once for each of the fields I want). Then for each remaining... |
Forum: Python Feb 8th, 2009 |
| Replies: 14 Views: 817 So there will be 9126 columns of output (one extra for the headings)
and all of the values from one input file will be on one line in the output file?
Is the output file intended to be human... |
Forum: Python Feb 8th, 2009 |
| Replies: 14 Views: 817 It might help if you could write (in your own words) what it is that you think you need the program to do.
The first example looks something like:
There are 10 (or N?) input files with... |
Forum: Python Jan 21st, 2009 |
| Replies: 4 Views: 981 |
Forum: Python Jan 21st, 2009 |
| Replies: 4 Views: 981 On line 2, r is coming from the values in the dictionary, not the keys.
So you can't use it as a key on line 8, you can't index a dictionary by the definition.
You could either test to see if the... |
Forum: Python Jan 20th, 2009 |
| Replies: 11 Views: 565 Your implementation of find_text would only attempt to iterate to lower elements if the current element had no text.
Having text does not preclude having child nodes.
I rewrote your find_text... |
Forum: Python Jan 12th, 2009 |
| Replies: 7 Views: 1,275 Whether or not the text of the PDF is 'available' is an option for the PDF publisher. I remember several tech documents that were designed intentionally to not allow you to copy the text out of them.... |
Forum: Python Jan 11th, 2009 |
| Replies: 10 Views: 786 That's what the comprehensions were for:
group1 = [listMain[x] for x in [0,4,9]] |
Forum: Python Jan 10th, 2009 |
| Replies: 10 Views: 786 I'm not quite sure what you're trying to ask for, but did you know you can take a slice of a list?
For example, this produces almost the same output as what you had before.
... |
Forum: Python Jan 10th, 2009 |
| Replies: 10 Views: 786 From your code, when you call sort(name):
if 'pile1'in ans:
sort(pile1)
if 'pile2'in ans:
sort(pile2)
if 'pile3'in ans:
sort(pile3)
You pass in one of the lists, pile1, pile2 or pile3.
... |
Forum: Python Jan 10th, 2009 |
| Replies: 10 Views: 786 The only place in your code where you attempt to print listMain is from inside sort, if the name passed to sort is 'pile1', right?
When do you ever pass the name 'pile1' to sort?
(You pass the... |
Forum: Python Jan 8th, 2009 |
| Replies: 7 Views: 693 To do more with the color, you're probably going to want to look at the component parts of the tuple.
For example, the following would count any pixel with more green than red and more green than... |
Forum: Python Jan 7th, 2009 |
| Replies: 7 Views: 693 The algorithm as posted only counts pixels that are green and only green. There is no provision for counting something that is 'almost' green.
The (0,255,0) represents the color...that's 0 parts... |
Forum: Python Jan 6th, 2009 |
| Replies: 1 Views: 424 This is the essential parts of the 'source' for the basic search form extracted from the web page you indicated:
<form action="/search.php#results" method="post">
<strong>Basic Search </strong>... |
Forum: Python Jan 1st, 2009 |
| Replies: 14 Views: 949 The reason it is main4() in my code is that this is the 4th version of the sort in the .py file main() was your version, main2() and main3() were versions of mine that did in another way. main4 is... |
Forum: Python Jan 1st, 2009 |
| Replies: 18 Views: 1,080 As I understand it, Python couldn't care less how many spaces / tabs you use other than requiring that all lines within a block must have the same amount of whitespace.
Any statements you have... |
Forum: Python Dec 30th, 2008 |
| Replies: 6 Views: 456 So ana and kata are moves in the fourth dimension of the matrix.
You mention giving a cell a reference to all 8 of its neighbors. That sounds like it might be the hardest part of building the data... |
Forum: Python Dec 29th, 2008 |
| Replies: 6 Views: 456 You didn't note any constraints other than "the array is mostly empty, and how can I make it smaller" so I wasn't concerned with any.
In the case of the dictionary, we would only store the data... |
Forum: Python Dec 29th, 2008 |
| Replies: 6 Views: 456 You could use a dictionary where the key was the composite index, something like key = "%d_%d_%d_%d" % (w,x,y,z) or key="W%dX%dY%dZ%d" % (w,x,y,z). I think the dictionary would manage the collection... |
Forum: Python Dec 26th, 2008 |
| Replies: 14 Views: 949 I think maybe we have gotten 'off track'. The original problem was
Most of the discussion (except for woooee's) has been about re-ordering the items on the line so you could use sort() (with the... |
Forum: Python Dec 25th, 2008 |
| Replies: 14 Views: 949 The return you have inside sorty will return from the function and the code that is 'supposed to read more data' will never get run.
What happened to names = infile.readlines() that read all the... |
Forum: Python Dec 23rd, 2008 |
| Replies: 6 Views: 428 Does your lower case letter L look like a 1?
It does on my screen. |
Forum: Python Dec 23rd, 2008 |
| Replies: 14 Views: 949 When you get to the actual sorting, you kinda need to compare numbers and not strings. When comparing strings, '1234' comes before '2', and that's just not right.
For the splitting of the name... |
Forum: Python Dec 20th, 2008 |
| Replies: 18 Views: 2,116 tutti,
We haven't been working on this thread for over 2 weeks...if you want to get help with your program, start a new thread and show us your work. |
Forum: Python Dec 19th, 2008 |
| Replies: 18 Views: 902 you're not supposed to take part of the discussion out of the thread...now if someone were to search and find this thread, they can't see what you learned.
For random number generation, I like the... |
Forum: Python Dec 12th, 2008 |
| Replies: 40 Views: 2,659 You moved the lines too far out...(sigh)
import random
#list of words the computer will be picking
word_list = ['python', 'jumble', 'easy', 'difficult', 'answer', 'tracer', 'muffin']
print... |
Forum: Python Dec 12th, 2008 |
| Replies: 40 Views: 2,659 Can you use functions...you're having a hard time keeping the indenting right.
lines 31-38 should be out one indent...they need to be 'inside' the while guess_count < 5 but not 'inside' the while... |
Forum: Python Dec 11th, 2008 |
| Replies: 40 Views: 2,659 When I put the while loop where it was supposed to go, I got the following from running it:
I'm picking one of the 7 words from a secret list
Computer has selected secret word 6 letters.
... |
Forum: Python Dec 11th, 2008 |
| Replies: 40 Views: 2,659 In my test app, I didn't limit them to entering one letter, but I validated what they typed and complained if it was more than one character.
You could replace the raw_input and the first if test... |
Forum: Python Dec 11th, 2008 |
| Replies: 40 Views: 2,659 you're still missing the elif guess in correct: before the print guess,"is correct"
I'm hoping its just the broken code tag that caused it, or you lost your indentation. |
Forum: Python Dec 11th, 2008 |
| Replies: 3 Views: 406 def isWhole(num):
return num == int(num)
Works pretty well, but can fail for numbers that are really close to whole:
Test code and output
for ii in xrange(1,20):
f =... |
Forum: Python Dec 10th, 2008 |
| Replies: 40 Views: 2,659 I tried to explain about indenting before...
Your while loop that starts on line 13 only contains line 14 and line 15. Line 16 will not be executed until the while is complete.
You lost an elif... |
Forum: Python Dec 9th, 2008 |
| Replies: 40 Views: 2,659 The error I posted was from the command-line compiler.
I'm running:
python --version
Python 2.5.2
The error message was generated with: |
Forum: Python Dec 9th, 2008 |
| Replies: 40 Views: 2,659 ok, you are aware the indentation is CRITICAL in python applications?
In this first case, only one line is executed 10 times and the output is 11 lines long:
for ii in xrange(10):
print... |
Forum: Python Dec 8th, 2008 |
| Replies: 40 Views: 2,659 Close, but the line 4 needs to follow like 5 and print the len of the random_word.
As written, line 4 (if it used 'len' instead of 'leg') would tell you how many words there were.
print "I'm... |
Forum: Python Dec 8th, 2008 |
| Replies: 40 Views: 2,659 The problem wasn't to remove references to random_word but to set it to a random selection from your list of words.
You use guess_word in many places to mean many different things, this is... |
Forum: Python Dec 8th, 2008 |
| Replies: 40 Views: 2,659 The while loop starting on line 45 is NOT supposed to be inside the while loop from line 10. Move it out to the same level as the while from line 10.
You can not run the posted code...the posted... |