Again, I try to deal with exercise from a book Think Python version 1.1.19., exercise 9.2. (case study: world play)
My contents of the words.txt is:
Toto je moj prvy pokus otvorit a citat subor.
Vela stastia "
Thing is, if you have a look at a scrip below you will see that the result is just showing whole line. for example 1 line (Ahoj,) doesn't contain e in the word Ahoj, so result is Ahoj,. But 2 line is more interesting. There are more words in the line so I am interesting to show (as a result) words which doesn't contain e. As you can see, result should be following:
Toto moj prvy pokus otvorit a citat subor.
As you can seen 'je' is omited. I think that is the case of the exercise, but I don't know how to read word by word in all lines, for that I would approciate any raesonable hint because I am stuck.
def main(): fin = open('words.txt') for words in fin: word = words.strip() if has_no_e(word): print word def has_no_e(word): for letter in word: if letter =='e': return False return True main()
Thank you Vlady
Edited 6 Years Ago by vegaseat: added code tags