I got this code from the internet.

import random

#create a sequence of words to choose from
name = ("stephen","bob", "robert","craig")

# pick one word randomly from the sequence
word = random.choice(name)

#create a variabe to use later to see if the guess is correct
correct = word

# create hints for all the jumbled words
hint0 = ("\nbegins with s")
hint1 =("\nbegins with b")
hint2 = ("\nbegins with r")
hint3 = ("\nbegins with c")



# create a jumbled version of the word
jumble = ""

while word:
    position = random.randrange(len(word))
    jumble += word[position]
    word = word[:position] + word[(position +1):]

# start the game

print (
    """
            Welcome to the word Jumble!

        Unsramble the letters to make a word.

      (Press the enter key at prompt to quit.)

    """
    )


print("\nThe jumble word is: ",jumble)


guess = input("\nTake a guess: ")

guess = guess.lower()

score = 0


while guess != correct and guess !="":
    print("\nYour guess is wrong: ")
    hint_prompt = input("\nWould you like a hint? YES/NO: ")
    hint_prompt = hint_prompt.lower()
    if hint_prompt == "yes" and correct == name[0]:
        print(hint0)
    elif hint_prompt == "yes" and correct == name[1]:
        print(hint1)
    elif hint_prompt == "yes" and correct == name[2]:
        print(hint2)
    elif hint_prompt == "yes" and correct == name[3]:
        print(hint3)
    elif hint_prompt == "no":
        score += 50


    guess = input("\nTake another guess: ")
    guess = guess.lower()


    if guess == correct and hint_prompt == "no":
        print("\nBecause you never asked for a hint you get ",score," points.")



print("\nWell done, thanks for playing.")
input("\nPress the enter key to exit.")

Can someone please explain what this bit of code means in relation to the program.

hint_prompt = hint_prompt.lower()

Many thanks in advance

hint_prompt = hint_prompt.lower()

the string is converted to all lower case

Edited 2 Years Ago by David W

Thanks very much, now you have mentioned it, it is obvious lol.

This question has already been answered. Start a new discussion instead.