Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word Game
#1
Hi everyone,

I hope you're all keeping safe during this time.

I'm trying to create a word game in Python (using Thonny), whereby the user has to come up with a word from a random sample of ten letters.

I have managed to get the code to match whereby, if letters not in the sample, are used, the user is reminded to use the ones in the sample.

But I'm finding that my "print" command is printing for each character used in the word, as opposed to just the word itself. It is also increasing the score three times instead of once.

Please see image below for reference.


import random
parhau = True

letters = []
for num in range (97,123):
    letters.append (chr(num))

x = 0
rlist = random.sample(letters,10)
print (rlist)
while parhau:
    word = str(input ("Please enter a word "))
    for ch in str(word):
        if not ch in rlist [1:11]:
            print ("Nay - try again!")
        if ch in rlist and len (word) >= 3:
            x += 1
            print ("Boom! Your score is now " + str(x + 1) )
I am a complete beginner with Python, so please do bear with me.

If you can help me, I would be very grateful.

Kind regards,
paulmerton4pope
Reply


Messages In This Thread
Word Game - by paulmerton4pope - Jul-10-2020, 12:44 PM
RE: Word Game - by GOTO10 - Jul-10-2020, 04:51 PM
RE: Word Game - by menator01 - Jul-10-2020, 04:58 PM
RE: Word Game - by menator01 - Jul-10-2020, 07:10 PM
RE: Word Game - by paulmerton4pope - Jul-11-2020, 02:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Guess the word game help jackthechampion 3 3,032 Sep-06-2023, 06:51 AM
Last Post: Pedroski55
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,512 Aug-12-2021, 04:25 PM
Last Post: palladium
  Python Speech recognition, word by word AceScottie 6 16,018 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  print a word after specific word search evilcode1 8 4,861 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  difference between word: and word[:] in for loop zowhair 2 3,686 Mar-03-2018, 07:24 AM
Last Post: zowhair

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020