KRIKOSOLI
KRIKOSOLI

Reputation: 1

CS50 Final unsatisfied Conditions

I am currently doing my CS50 final project problem and have encountered quite a problem. Below is my code and the error message that appears whenever I give it in. Any help as to how to fix an issue that I'm not sure why is there would be great help. My code works as expected, and runs well. However CS50 just isnt working whenever I try. (Please ignore the README errors as that is just a length problem)

My main problem is that it isnt detecting the 3 functions and the main function and the the whole py thing.

from termcolor import colored
import random

def main():
    run_game()
#I have the next couple of functions all put into effect in the run_game function. Therefore only need to do run game.


#This function takes a word to print, and an array containing the colours each letter should be printed input
#The first character in the word will be printed in the first colour in the array and so forth

def present_results(word, colours):
    if(len(word)==5 and len(colours) == 5):
        print(colored(word[0],colours[0]),
      colored(word[1],colours[1]),
      colored(word[2],colours[2]),
      colored(word[3],colours[3]),
      colored(word[4],colours[4]))
    else:
        print('Invalid input to present_results, word or array incorrect length, both should be length 5')
        print('[DEBUG] word length:',len(word),'colour array length:',len(colours))

#The following are tests for the present_results and randint functions

word = "PRINT"
colors = ['green','white','yellow','white','yellow']
#present_results(word, colors)




def generate_word ():
    words=['thorn','thick','light','might','cabin','paste','vocal','abode','right','urban','ghost',' zebra',
          'grail','tower','brave','crave','chase','image','night','print', 'shame','table','fable','diary','train', 'prick', 'stick', 'slice', 'solid',
          'space', 'other', 'about' , 'which', 'witch', 'faith', 'clown', 'scowel', 'towel', 'shelf' , 'stone', 'earth', 'extra', 'adieu', 'entry',
          'evict', 'clone', 'shady', 'stock', 'corks', 'actor']

#List of 50 words to pick from

    index=random.randint(0,49)
    return words[index]

#A lot of words thats returned to be the word that is guessed. its a list and using the random generator it is picked randomly and returned

def letter_in_word (string,letter):
    if letter in string:
        return True

    else:
        return False
#Straightforward, whether the letter is present in the word of not it returns true/false


def letter_in_place  (string,letter,index):
    if string[index]==letter:
        return True

    else:
        return False
#similiar to the top one, if it is in the correct or incorrect spot, it returns true/false



def guess_word (answer,guess):

    colors=[]
    for i in range(len(answer)):
        temp=letter_in_place(answer,guess[i],i)
        if temp==True:
            colors.append('green')

        elif temp==False:
            temp=letter_in_word(answer,guess[i])
            if temp==True:
                colors.append('yellow')

            elif temp==False:
                colors.append('white')

    return guess,answer,colors
#Basically colour cordinated function where in a loop if it follows the placement it is green, the letter is present it is yellow, and if none just white. Using the "in place" function and "letter in word" one too.

def run_game():
    answer=generate_word()
    for i in range(0,6):
        guess=input("Enter a guess: ")
        if guess==answer:
            print("Great Job,",answer, "is the right word!" )
            return
        guess,answer,colors=guess_word(answer,guess)
        present_results(guess,colors)

    print("All 6 Attempts Were Used, Try Again!")

#uses all the above functions and puts it all in one to simplify for the main function.


if __name__ == "__main__":
    main()

The code runs well and as expected, however the error that pops up is this:

:) README.md exists Log checking that README.md exists...

:( final project details Cause Description is not long enough.

:| project.py exists Cause can't check until a frown turns upside down

:| main function exists Cause can't check until a frown turns upside down

:| implemented at least 3 top-level functions other than main Cause can't check until a frown turns upside down

EDIT: Below is a copy paste of my README.MD file its roughly 450 words and is quite long and detailed. I am unsure of the problem. Thank you!

#### Video Demo:  <https://youtu.be/jVo5LkGE3Mk>
#### Description:

My name is Karim Osman and I wrote for my final project in CS50s intro to python course a game.

TERMLE is a heavily inspired game from the 2020-2021 hit web browser game called WORDLE. It gained such popularity where it was bought by the New York Times.

It follows a basic concept of the user has six attempts to guess the correct word. The user recieves color-coded hints with each guess indicating a letters presence and position. Green for the letter that is in the correct position and present in the letter. Yellow for incorrect position and present letter. Finally grey for letter is not present in the word.

Following these basic guidelines of WORDLE, I made a similiar game called TERMLE. It uses the same colors and the same concepts with a few minor adjustments. One major difference in that the words present are randomly picked from a list of fifty words within the generate_word function using the random library. From these words there are none that have a duplicate letter, I.E: Eagle - Looks. In addition, the user can play as much as they desire, unlike WORDLE where the user is restricted to one session per day, whether correct or incorrect.

I breifly mentioned the beggining of function above. The generate_word function takes from a list of fifty words, all five letters, and uses the imported random task to return a selected string outside of the function. After so, we have two quite similiar and simple functions called letter_in_place and letter_in_word. The word one sees if the character is present in the returned string, and claims it either as True or False. The place one follows a similiar concept. If the letter is present in the word at a specific placement I.E: "i" is present in brick[2], it will return True, otherwise False.

Using the two above functions we create the next and more important function guess_word. This begins to take into account the placement and present characters in the returned word of the game. Alongside so, it begins color responding to the users input. With the append function, starting with green if the letter and placement is correct it will become true, otherwise it will move to yellow where only the letter is correct, then finally it will go grey where neither the placement or the letter is correct.

Finally, condensing all the above functions into use in the run_game function. This is where the user is prompted an input and the sole call in the main function due to how pratical it is. Prints according to whether the user wins or loses, and uses the presents_results function to properly display the answers.

I am unsure if the formatting is wrong or if I should create it on github and not the project folder. I am very lost here.

Upvotes: 0

Views: 1329

Answers (1)

kcw78
kcw78

Reputation: 8046

I'm pretty sure that the 2nd line (Cause Description is not long enough.) has nothing to do with your code and means 1 of 2 things:

  1. Your README.MD isn't long enough, or
  2. You didn't you follow the instructions about using Markdown syntax under How to Submit .

For reference, my project README word count was 467 and line count was 51. Also, here is the Markdown syntax you need use to to mark your Description.

# YOUR PROJECT TITLE
#### Video Demo:  <URL HERE>
#### Description:
TODO

Upvotes: 0

Related Questions