Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Talknerdytome

  • one year 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
    • one year 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
    • one year 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

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.