# I need some help creating a word game in Python

**URL:** <https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525>\
**Category:** Python Help\
**Created:** [October 29, 2022, 4:41pm UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525 "2022-10-29T16:41:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wthiierry](https://avatars.discourse-cdn.com/v4/letter/w/58f4c7/32.png) [@wthiierry](https://discuss.python.org/u/wthiierry)\
**Post date:** [October 29, 2022, 4:41pm UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525/1 "2022-10-29T16:41:05Z")

</div>

Hello, I’ve recently started to learn about Python (for about 2 months), and I need some help to create a word based game, similar to a game called “Wordle”, for this I need to do the following:

Have a secret word stored in the program.

Prompt the user for a guess.

Continue looping as long as that guess is not correct.

Calculate the number of guesses and display it at the end.

Add a check to verify that the length of the guess is the same as the length of the secret word. If it is not, display a message. If they are the same, then proceed to give the hint.

Make sure to account for the following in your hints:

Letters that are not present at all in the secret word (underscore \_).

Letters that are present in the secret word, but in a different spot (lowercase).

Letters that are present in the secret word at that exact spot spot (uppercase).

Until now my code looks like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/3/3f2fd674a17d2d53970ec4e387f7e308e2aace7a.png)

I don’t know how to do last parts of the code, the lower.case, upper.case hints, and the error message displayed if the user types the wrong amount of letters.

If someone can help me with this, I will be grateful !

---

<div class="post-metadata">

**Author:** ![eschan145](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@eschan145](https://discuss.python.org/u/eschan145)\
**Post date:** [October 29, 2022, 6:50pm UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525/2 "2022-10-29T18:50:12Z")

</div>

Try this:

```auto
if len(guess) != len(secret_word):
    print("The word is not the right length!")

```

The `len()` function returns the length of the string.

There is a `lower()` function for strings.

`"ABCD".lower()` returns `"abcd"`

---

<div class="post-metadata">

**Author:** ![wthiierry](https://avatars.discourse-cdn.com/v4/letter/w/58f4c7/32.png) [@wthiierry](https://discuss.python.org/u/wthiierry)\
**Post date:** [October 30, 2022, 12:45am UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525/3 "2022-10-30T00:45:03Z")

</div>

Thanks for that tip, what about the hints part:  
Letters that are present in the secret word, but in a different spot (lowercase).

Letters that are present in the secret word at that exact spot spot (uppercase).

Do you have any tips for that?

---

<div class="post-metadata">

**Author:** ![cameron](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cameron/32/2658_2.png) [@cameron](https://discuss.python.org/u/cameron)\
**Post date:** [October 30, 2022, 1:05am UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525/4 "2022-10-30T01:05:52Z")

</div>

Sets: [Built-in Types — Python 3.11.0 documentation](https://docs.python.org/3/library/stdtypes.html#set)

Cheers,  
Cameron Simpson [cs@cskk.id.au](mailto:cs@cskk.id.au)

---

<div class="post-metadata">

**Author:** ![wthiierry](https://avatars.discourse-cdn.com/v4/letter/w/58f4c7/32.png) [@wthiierry](https://discuss.python.org/u/wthiierry)\
**Post date:** [October 30, 2022, 7:01pm UTC](https://discuss.python.org/t/i-need-some-help-creating-a-word-game-in-python/20525/6 "2022-10-30T19:01:19Z")

</div>

It’s supposed to work like this:

 ![image.png](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/c/caa39a8d6298eea2d2cfa9b37d328f245d58f9db.png)
