At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
looks reasonable, maybe try some print statements like this http://dpaste.com/1383878/
Hi , it still don't work. Traceback (most recent call last): File "
", line 1, in
File "/Users/Avatar/Documents/problem 4", line 135, in find_best_shift
print 'shift:  words: '.format(shift, potential_words)
AttributeError: 'str' object has no attribute 'format'
how 'bout this http://dpaste.com/1384625/
s = apply_shift("love", 3) >>> s ' ORYH' >>> find_best_shift(wordlist, s) shift: 0 words: ['ORYH'] 0 Samething than before!
what could be wrong? what did the print statement print? did it print what you expected it to print? did it print what it should have printed? how many times did it print? how many times should it have printed? what other steps have you taken to find the problem and what were the results? print statements can tell you a lot about how your code is executing
I reallt don't know what could be wrong with my function.The "print statement " print teh shift wich were 0 and the ecoded letter. It should print a number != to 0,it should print it one time and it printed exactly one time.
is the print statement in a loop? how many times should the loop execute?
The print statement iss not in a loop.
did you write the function? the print statement is in a loop. ``` >>> >>> for shift in range(27): print shift 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 >>> ``` http://docs.python.org/2.7/tutorial/controlflow.html#for-statements
I wrote a print statement. def find_best_shift(wordlist, text): max_num_real_words = 0 best_shift = 0 for shift in range(27): shifted_text = apply_shift(text, shift) potential_words = shifted_text.split() print 'shift:', shift, ' words:', potential_words num_real_words = 0 for word in potential_words: if is_word(wordlist, word): num_real_words += 1 if num_real_words > max_num_real_words: max_num_real_words = num_real_words best_shift = shift return best_shift
ok ... when you call the function, how many times does it print? how many times should it print?
I'd suggest to use print stmt: print shifted_text and see the output of apply_shift proc
I try all it still don't work. So do you have an idea about how can I import feedparser?
different topic, start a new thread. if you want your best_shift function to work you need to examine the position of your return statement. did you write the function you posted?
Thank you I will try
bwCA - exactly, problem with 'return' :) silly :)
I change my return statement place it still doesn't work
well, do not change the place :) are you certain it is at the very end of your def?