Python Forum
Python Hangman Game - Multiple Letters Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Hangman Game - Multiple Letters Problem
#3
(Jun-04-2020, 02:26 PM)Clunk_Head Wrote: The find function returns the index of the first instance found. That's why it stops working after the first one is found. If it doesn't find an instance then it returns -1. What you need to do is keep running find in a loop until it returns -1.
Something like:
while full_word.find(guess):
    selected_word = selected_word[:checker] + guess + selected_word[checker+1:]

I'm not getting this to work. Wouldn't it still just have the same problem? full_word is the original word, and selected_word is the starred out version. If I just keep running .find on full_word with guess, surely it would still keep ending at the first index?
Reply


Messages In This Thread
RE: Python Hangman Game - Multiple Letters Problem - by t0rn - Jun-04-2020, 04:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,568 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Stacking Problem in a game. HelloTobi22 2 1,007 Aug-05-2022, 09:48 AM
Last Post: HelloTobi22
  Problem with my pong game code Than999 8 3,876 May-15-2022, 06:40 AM
Last Post: deanhystad
  Problem restricting user input in my rock paper scissors game ashergreen 6 4,637 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  multiple condition if statement problem FelixReiter 3 2,613 Jan-11-2021, 08:07 AM
Last Post: FelixReiter
  eliminating letters when typed in python window deebo 0 1,745 Jan-05-2021, 09:26 AM
Last Post: deebo
  Guessing game problem IcodeUser8 7 3,658 Jul-19-2020, 07:37 PM
Last Post: IcodeUser8
  game of the goose - dice problem koop 4 3,502 Apr-11-2020, 02:48 PM
Last Post: ibreeden
  Problem with accepting multiple string inputs Ryan_Todd 5 2,964 Jan-22-2020, 06:12 PM
Last Post: buran
  Plot multiple csv into one graph problem with visualize linkxxx86 1 5,736 Oct-14-2019, 05:54 PM
Last Post: linkxxx86

Forum Jump:

User Panel Messages

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