-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError located at a line that does not exist #22258
Comments
Never mind, the code wasn't showing up properly on my screen. I have found & solved the issue after copying & pasting the entire code a second time. |
Description
What steps will reproduce the problem?
Was writing code, suddenly Spyder claimed I had an 'unterminated triple-quoted string literal' located at a line that didn't exist (i.e. my code ended at around line 390, it claimed the error was at line 444). I tried to delete the chunks of the code to firgure out where exactly the error was, but even when I deleted all of the code on the file it still claimed I had the 'unterminated string literal'.
I'm not sure how to reproduce it - maybe I can paste the entire code?
Here it is:
6.0001 Problem Set 3
The 6.0001 Word Game
Created by: Kevin Luu and Jenna Wiens
Name :
Collaborators :
Time spent :
import math
import random
import string
VOWELS = 'aeiou'
CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
HAND_SIZE = 7
SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10, '*': 0}
-----------------------------------
Helper code
(you don't need to understand this helper code)
WORDLIST_FILENAME = "words.txt"
def load_words():
"""
Returns a list of valid words. Words are strings of lowercase letters.
def get_frequency_dict(sequence):
"""
Returns a dictionary where the keys are elements of the sequence
and the values are integer counts, for the number of times that
an element is repeated in the sequence.
(end of helper code)
-----------------------------------
word_list = load_words()
Problem #1: Scoring a word
def get_word_score(word, n):
"""
Returns the score for a word. Assumes the word is a
valid word.
Make sure you understand how this function works and what it does!
def display_hand(hand):
"""
Displays the letters currently in the hand.
Make sure you understand how this function works and what it does!
You will need to modify this for Problem #4.
def deal_hand(n):
"""
Returns a random hand containing n lowercase letters.
ceil(n/3) letters in the hand should be VOWELS (note,
ceil(n/3) means the smallest integer not less than n/3).
Problem #2: Update a hand by removing letters
def update_hand(hand, word):
"""
Does NOT assume that hand contains every letter in word at least as
many times as the letter appears in word. Letters in word that don't
appear in hand should be ignored. Letters that appear in word more times
than in hand should never result in a negative count; instead, set the
count in the returned hand to 0 (or remove the letter from the
dictionary, depending on how your code is structured).
Problem #3: Test word validity
def is_valid_word(word, hand, word_list):
"""
Returns True if word is in the word_list and is entirely
composed of letters in the hand. Otherwise, returns False.
Does not mutate hand or word_list.
Problem #5: Playing a hand
def calculate_handlen(hand):
"""
Returns the length (number of letters) in the current hand.
def play_hand(hand, word_list):
Problem #6: Playing a game
procedure you will use to substitute a letter in a hand
def substitute_hand(hand, letter):
"""
Allow the user to replace all copies of one letter in the hand (chosen by user)
with a new letter chosen from the VOWELS and CONSONANTS at random. The new letter
should be different from user's choice, and should not be any of the letters
already in the hand.
def play_game(word_list):
"""
Allow the user to play a series of hands
Build data structures used for entire session and play game
Do not remove the "if name == 'main':" line - this code is executed
when the program is run directly, instead of through an import statement
if name == 'main':
word_list = load_words()
play_game(word_list)
for is_valid_word
"""
failure=False
Traceback
Versions
Dependencies
The text was updated successfully, but these errors were encountered: