[Tutor] Need help with code

Joel Goldstick joel.goldstick at gmail.com
Wed Apr 19 12:17:09 EDT 2017


You most likely have no file named words.txt in the directory from
which you are running your code.

On Mon, Apr 17, 2017 at 10:12 PM, Tyler Seacrist <seacristt at hotmail.com> wrote:
> Hello,
>
>
> How do I avoid this error message everytime I utilize wordlist = open("words.text") ?
>
>>>> wordlist = open("words.txt")
> Traceback (most recent call last):
>   File "<pyshell#303>", line 1, in <module>
>     wordlist = open("words.txt")
> FileNotFoundError: [Errno 2] No such file or directory: 'words.txt'
>>>> def calculate_abecedarian():
> total_count = 0
> for word in wordlist:
> if is_abecedarian(word):
> print (word)
> total_count += 1
> return total_count
>
> or
>
>>>> if __name__ == '__main__':
>     fin = open('words.txt', 'r')
>     print (no_contain(fin))
>
>
> Traceback (most recent call last):
>   File "<pyshell#213>", line 2, in <module>
>     fin = open('words.txt', 'r')
> FileNotFoundError: [Errno 2] No such file or directory: 'words.txt'
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays


More information about the Tutor mailing list