Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Talknerdytome

  • 3 years ago

Python 3 - PS2 - Helper Code I'm doing this class in Python 3 because it's more up-to-date. I tried editing the Helper Code for Hangman, but I can only get it to load 1 word instead of all of the words. I get "Loading word list from file..." and then "1 words loaded." I changed inFile = open(WORDLIST_FILENAME, 'r', 0) to just inFile = open(WORDLIST_FILENAME, 'r') and wordlist = string.split(line) to wordlist = WORDLIST_FILENAME.split(line). I've also tried passing no arguments through split along with whitespace and a few other things as well as using .splitlines etc.

  • This Question is Closed
  1. Talknerdytome
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    What am I doing wrong/what is the best way to do this in Python 3? I've uploaded my new code and the original code so that it's more clear.

    1 Attachment
  2. Talknerdytome
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I figured it out! I was just reading the string 'words.txt' when I created wordlist so it was a list of length one which had one string, 'words.txt.' I updated it to wordlist=line.split() and now get the appropriate statements.

  3. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy